You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

centernet_resnet18_dcnv2_140e_coco.py 4.0 kB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. _base_ = [
  2. '../_base_/datasets/coco_detection.py',
  3. '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
  4. ]
  5. model = dict(
  6. type='CenterNet',
  7. backbone=dict(
  8. type='ResNet',
  9. depth=18,
  10. norm_eval=False,
  11. norm_cfg=dict(type='BN'),
  12. init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet18')),
  13. neck=dict(
  14. type='CTResNetNeck',
  15. in_channel=512,
  16. num_deconv_filters=(256, 128, 64),
  17. num_deconv_kernels=(4, 4, 4),
  18. use_dcn=True),
  19. bbox_head=dict(
  20. type='CenterNetHead',
  21. num_classes=80,
  22. in_channel=64,
  23. feat_channel=64,
  24. loss_center_heatmap=dict(type='GaussianFocalLoss', loss_weight=1.0),
  25. loss_wh=dict(type='L1Loss', loss_weight=0.1),
  26. loss_offset=dict(type='L1Loss', loss_weight=1.0)),
  27. train_cfg=None,
  28. test_cfg=dict(topk=100, local_maximum_kernel=3, max_per_img=100))
  29. # We fixed the incorrect img_norm_cfg problem in the source code.
  30. img_norm_cfg = dict(
  31. mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
  32. train_pipeline = [
  33. dict(type='LoadImageFromFile', to_float32=True, color_type='color'),
  34. dict(type='LoadAnnotations', with_bbox=True),
  35. dict(
  36. type='PhotoMetricDistortion',
  37. brightness_delta=32,
  38. contrast_range=(0.5, 1.5),
  39. saturation_range=(0.5, 1.5),
  40. hue_delta=18),
  41. dict(
  42. type='RandomCenterCropPad',
  43. crop_size=(512, 512),
  44. ratios=(0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3),
  45. mean=[0, 0, 0],
  46. std=[1, 1, 1],
  47. to_rgb=True,
  48. test_pad_mode=None),
  49. dict(type='Resize', img_scale=(512, 512), keep_ratio=True),
  50. dict(type='RandomFlip', flip_ratio=0.5),
  51. dict(type='Normalize', **img_norm_cfg),
  52. dict(type='DefaultFormatBundle'),
  53. dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels'])
  54. ]
  55. test_pipeline = [
  56. dict(type='LoadImageFromFile', to_float32=True),
  57. dict(
  58. type='MultiScaleFlipAug',
  59. scale_factor=1.0,
  60. flip=False,
  61. transforms=[
  62. dict(type='Resize', keep_ratio=True),
  63. dict(
  64. type='RandomCenterCropPad',
  65. ratios=None,
  66. border=None,
  67. mean=[0, 0, 0],
  68. std=[1, 1, 1],
  69. to_rgb=True,
  70. test_mode=True,
  71. test_pad_mode=['logical_or', 31],
  72. test_pad_add_pix=1),
  73. dict(type='RandomFlip'),
  74. dict(type='Normalize', **img_norm_cfg),
  75. dict(type='DefaultFormatBundle'),
  76. dict(
  77. type='Collect',
  78. meta_keys=('filename', 'ori_shape', 'img_shape', 'pad_shape',
  79. 'scale_factor', 'flip', 'flip_direction',
  80. 'img_norm_cfg', 'border'),
  81. keys=['img'])
  82. ])
  83. ]
  84. dataset_type = 'CocoDataset'
  85. data_root = 'data/coco/'
  86. # Use RepeatDataset to speed up training
  87. data = dict(
  88. samples_per_gpu=16,
  89. workers_per_gpu=4,
  90. train=dict(
  91. _delete_=True,
  92. type='RepeatDataset',
  93. times=5,
  94. dataset=dict(
  95. type=dataset_type,
  96. ann_file=data_root + 'annotations/instances_train2017.json',
  97. img_prefix=data_root + 'train2017/',
  98. pipeline=train_pipeline)),
  99. val=dict(pipeline=test_pipeline),
  100. test=dict(pipeline=test_pipeline))
  101. # optimizer
  102. # Based on the default settings of modern detectors, the SGD effect is better
  103. # than the Adam in the source code, so we use SGD default settings and
  104. # if you use adam+lr5e-4, the map is 29.1.
  105. optimizer_config = dict(
  106. _delete_=True, grad_clip=dict(max_norm=35, norm_type=2))
  107. # learning policy
  108. # Based on the default settings of modern detectors, we added warmup settings.
  109. lr_config = dict(
  110. policy='step',
  111. warmup='linear',
  112. warmup_iters=1000,
  113. warmup_ratio=1.0 / 1000,
  114. step=[18, 24]) # the real step is [18*5, 24*5]
  115. runner = dict(max_epochs=28) # the real epoch is 28*5=140

No Description

Contributors (3)