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.

ssdlite_mobilenetv2_scratch_600e_coco.py 4.8 kB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. _base_ = [
  2. '../_base_/datasets/coco_detection.py', '../_base_/default_runtime.py'
  3. ]
  4. model = dict(
  5. type='SingleStageDetector',
  6. backbone=dict(
  7. type='MobileNetV2',
  8. out_indices=(4, 7),
  9. norm_cfg=dict(type='BN', eps=0.001, momentum=0.03),
  10. init_cfg=dict(type='TruncNormal', layer='Conv2d', std=0.03)),
  11. neck=dict(
  12. type='SSDNeck',
  13. in_channels=(96, 1280),
  14. out_channels=(96, 1280, 512, 256, 256, 128),
  15. level_strides=(2, 2, 2, 2),
  16. level_paddings=(1, 1, 1, 1),
  17. l2_norm_scale=None,
  18. use_depthwise=True,
  19. norm_cfg=dict(type='BN', eps=0.001, momentum=0.03),
  20. act_cfg=dict(type='ReLU6'),
  21. init_cfg=dict(type='TruncNormal', layer='Conv2d', std=0.03)),
  22. bbox_head=dict(
  23. type='SSDHead',
  24. in_channels=(96, 1280, 512, 256, 256, 128),
  25. num_classes=80,
  26. use_depthwise=True,
  27. norm_cfg=dict(type='BN', eps=0.001, momentum=0.03),
  28. act_cfg=dict(type='ReLU6'),
  29. init_cfg=dict(type='Normal', layer='Conv2d', std=0.001),
  30. # set anchor size manually instead of using the predefined
  31. # SSD300 setting.
  32. anchor_generator=dict(
  33. type='SSDAnchorGenerator',
  34. scale_major=False,
  35. strides=[16, 32, 64, 107, 160, 320],
  36. ratios=[[2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3]],
  37. min_sizes=[48, 100, 150, 202, 253, 304],
  38. max_sizes=[100, 150, 202, 253, 304, 320]),
  39. bbox_coder=dict(
  40. type='DeltaXYWHBBoxCoder',
  41. target_means=[.0, .0, .0, .0],
  42. target_stds=[0.1, 0.1, 0.2, 0.2])),
  43. # model training and testing settings
  44. train_cfg=dict(
  45. assigner=dict(
  46. type='MaxIoUAssigner',
  47. pos_iou_thr=0.5,
  48. neg_iou_thr=0.5,
  49. min_pos_iou=0.,
  50. ignore_iof_thr=-1,
  51. gt_max_assign_all=False),
  52. smoothl1_beta=1.,
  53. allowed_border=-1,
  54. pos_weight=-1,
  55. neg_pos_ratio=3,
  56. debug=False),
  57. test_cfg=dict(
  58. nms_pre=1000,
  59. nms=dict(type='nms', iou_threshold=0.45),
  60. min_bbox_size=0,
  61. score_thr=0.02,
  62. max_per_img=200))
  63. cudnn_benchmark = True
  64. # dataset settings
  65. dataset_type = 'CocoDataset'
  66. data_root = 'data/coco/'
  67. img_norm_cfg = dict(
  68. mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
  69. train_pipeline = [
  70. dict(type='LoadImageFromFile', to_float32=True),
  71. dict(type='LoadAnnotations', with_bbox=True),
  72. dict(
  73. type='PhotoMetricDistortion',
  74. brightness_delta=32,
  75. contrast_range=(0.5, 1.5),
  76. saturation_range=(0.5, 1.5),
  77. hue_delta=18),
  78. dict(
  79. type='Expand',
  80. mean=img_norm_cfg['mean'],
  81. to_rgb=img_norm_cfg['to_rgb'],
  82. ratio_range=(1, 4)),
  83. dict(
  84. type='MinIoURandomCrop',
  85. min_ious=(0.1, 0.3, 0.5, 0.7, 0.9),
  86. min_crop_size=0.3),
  87. dict(type='Resize', img_scale=(320, 320), keep_ratio=False),
  88. dict(type='Normalize', **img_norm_cfg),
  89. dict(type='RandomFlip', flip_ratio=0.5),
  90. dict(type='Pad', size_divisor=320),
  91. dict(type='DefaultFormatBundle'),
  92. dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']),
  93. ]
  94. test_pipeline = [
  95. dict(type='LoadImageFromFile'),
  96. dict(
  97. type='MultiScaleFlipAug',
  98. img_scale=(320, 320),
  99. flip=False,
  100. transforms=[
  101. dict(type='Resize', keep_ratio=False),
  102. dict(type='Normalize', **img_norm_cfg),
  103. dict(type='Pad', size_divisor=320),
  104. dict(type='ImageToTensor', keys=['img']),
  105. dict(type='Collect', keys=['img']),
  106. ])
  107. ]
  108. data = dict(
  109. samples_per_gpu=24,
  110. workers_per_gpu=4,
  111. train=dict(
  112. _delete_=True,
  113. type='RepeatDataset', # use RepeatDataset to speed up training
  114. times=5,
  115. dataset=dict(
  116. type=dataset_type,
  117. ann_file=data_root + 'annotations/instances_train2017.json',
  118. img_prefix=data_root + 'train2017/',
  119. pipeline=train_pipeline)),
  120. val=dict(pipeline=test_pipeline),
  121. test=dict(pipeline=test_pipeline))
  122. # optimizer
  123. optimizer = dict(type='SGD', lr=0.015, momentum=0.9, weight_decay=4.0e-5)
  124. optimizer_config = dict(grad_clip=None)
  125. # learning policy
  126. lr_config = dict(
  127. policy='CosineAnnealing',
  128. warmup='linear',
  129. warmup_iters=500,
  130. warmup_ratio=0.001,
  131. min_lr=0)
  132. runner = dict(type='EpochBasedRunner', max_epochs=120)
  133. # Avoid evaluation and saving weights too frequently
  134. evaluation = dict(interval=5, metric='bbox')
  135. checkpoint_config = dict(interval=5)
  136. custom_hooks = [
  137. dict(type='NumClassCheckHook'),
  138. dict(type='CheckInvalidLossHook', interval=50, priority='VERY_LOW')
  139. ]

No Description

Contributors (2)