yolox-s_8xb8-300e_coco-face.py 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. train_cfg = dict(type='EpochBasedTrainLoop', max_epochs=300, val_interval=10)
  2. val_cfg = dict(type='ValLoop')
  3. test_cfg = dict(type='TestLoop')
  4. param_scheduler = [
  5. dict(
  6. type='mmdet.QuadraticWarmupLR',
  7. by_epoch=True,
  8. begin=0,
  9. end=5,
  10. convert_to_iter_based=True),
  11. dict(
  12. type='CosineAnnealingLR',
  13. eta_min=0.0005,
  14. begin=5,
  15. T_max=285,
  16. end=285,
  17. by_epoch=True,
  18. convert_to_iter_based=True),
  19. dict(type='ConstantLR', by_epoch=True, factor=1, begin=285, end=300)
  20. ]
  21. optim_wrapper = dict(
  22. type='OptimWrapper',
  23. optimizer=dict(
  24. type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005, nesterov=True),
  25. paramwise_cfg=dict(norm_decay_mult=0.0, bias_decay_mult=0.0))
  26. auto_scale_lr = dict(enable=False, base_batch_size=64)
  27. default_scope = 'mmdet'
  28. default_hooks = dict(
  29. timer=dict(type='IterTimerHook'),
  30. logger=dict(type='LoggerHook', interval=50),
  31. param_scheduler=dict(type='ParamSchedulerHook'),
  32. checkpoint=dict(type='CheckpointHook', interval=10, max_keep_ckpts=3),
  33. sampler_seed=dict(type='DistSamplerSeedHook'),
  34. visualization=dict(type='DetVisualizationHook'))
  35. env_cfg = dict(
  36. cudnn_benchmark=False,
  37. mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0),
  38. dist_cfg=dict(backend='nccl'))
  39. vis_backends = [dict(type='LocalVisBackend')]
  40. visualizer = dict(
  41. type='DetLocalVisualizer',
  42. vis_backends=[dict(type='LocalVisBackend')],
  43. name='visualizer')
  44. log_processor = dict(type='LogProcessor', window_size=50, by_epoch=True)
  45. log_level = 'INFO'
  46. load_from = 'https://download.openmmlab.com/mmdetection/' \
  47. 'v2.0/yolox/yolox_s_8x8_300e_coco/' \
  48. 'yolox_s_8x8_300e_coco_20211121_095711-4592a793.pth'
  49. resume = False
  50. img_scale = (640, 640)
  51. model = dict(
  52. type='YOLOX',
  53. data_preprocessor=dict(
  54. type='DetDataPreprocessor',
  55. pad_size_divisor=32,
  56. batch_augments=[
  57. dict(
  58. type='BatchSyncRandomResize',
  59. random_size_range=(480, 800),
  60. size_divisor=32,
  61. interval=10)
  62. ]),
  63. backbone=dict(
  64. type='CSPDarknet',
  65. deepen_factor=0.33,
  66. widen_factor=0.5,
  67. out_indices=(2, 3, 4),
  68. use_depthwise=False,
  69. spp_kernal_sizes=(5, 9, 13),
  70. norm_cfg=dict(type='BN', momentum=0.03, eps=0.001),
  71. act_cfg=dict(type='Swish')),
  72. neck=dict(
  73. type='YOLOXPAFPN',
  74. in_channels=[128, 256, 512],
  75. out_channels=128,
  76. num_csp_blocks=1,
  77. use_depthwise=False,
  78. upsample_cfg=dict(scale_factor=2, mode='nearest'),
  79. norm_cfg=dict(type='BN', momentum=0.03, eps=0.001),
  80. act_cfg=dict(type='Swish')),
  81. bbox_head=dict(
  82. type='YOLOXHead',
  83. num_classes=1,
  84. in_channels=128,
  85. feat_channels=128,
  86. stacked_convs=2,
  87. strides=(8, 16, 32),
  88. use_depthwise=False,
  89. norm_cfg=dict(type='BN', momentum=0.03, eps=0.001),
  90. act_cfg=dict(type='Swish'),
  91. loss_cls=dict(
  92. type='CrossEntropyLoss',
  93. use_sigmoid=True,
  94. reduction='sum',
  95. loss_weight=1.0),
  96. loss_bbox=dict(
  97. type='IoULoss',
  98. mode='square',
  99. eps=1e-16,
  100. reduction='sum',
  101. loss_weight=5.0),
  102. loss_obj=dict(
  103. type='CrossEntropyLoss',
  104. use_sigmoid=True,
  105. reduction='sum',
  106. loss_weight=1.0),
  107. loss_l1=dict(type='L1Loss', reduction='sum', loss_weight=1.0)),
  108. train_cfg=dict(assigner=dict(type='SimOTAAssigner', center_radius=2.5)),
  109. test_cfg=dict(score_thr=0.01, nms=dict(type='nms', iou_threshold=0.65)))
  110. data_root = 'data/coco/'
  111. dataset_type = 'CocoDataset'
  112. backend_args = dict(backend='local')
  113. train_pipeline = [
  114. dict(type='Mosaic', img_scale=(640, 640), pad_val=114.0),
  115. dict(
  116. type='RandomAffine', scaling_ratio_range=(0.1, 2),
  117. border=(-320, -320)),
  118. dict(
  119. type='MixUp',
  120. img_scale=(640, 640),
  121. ratio_range=(0.8, 1.6),
  122. pad_val=114.0),
  123. dict(type='YOLOXHSVRandomAug'),
  124. dict(type='RandomFlip', prob=0.5),
  125. dict(type='Resize', scale=(640, 640), keep_ratio=True),
  126. dict(
  127. type='Pad',
  128. pad_to_square=True,
  129. pad_val=dict(img=(114.0, 114.0, 114.0))),
  130. dict(type='FilterAnnotations', min_gt_bbox_wh=(1, 1), keep_empty=False),
  131. dict(type='PackDetInputs')
  132. ]
  133. train_dataset = dict(
  134. type='MultiImageMixDataset',
  135. dataset=dict(
  136. type='CocoDataset',
  137. data_root='data/coco/',
  138. ann_file='annotations/instances_train2017.json',
  139. data_prefix=dict(img='train2017/'),
  140. pipeline=[
  141. dict(type='LoadImageFromFile', backend_args=dict(backend='local')),
  142. dict(type='LoadAnnotations', with_bbox=True)
  143. ],
  144. filter_cfg=dict(filter_empty_gt=False, min_size=32)),
  145. pipeline=[
  146. dict(type='Mosaic', img_scale=(640, 640), pad_val=114.0),
  147. dict(
  148. type='RandomAffine',
  149. scaling_ratio_range=(0.1, 2),
  150. border=(-320, -320)),
  151. dict(
  152. type='MixUp',
  153. img_scale=(640, 640),
  154. ratio_range=(0.8, 1.6),
  155. pad_val=114.0),
  156. dict(type='YOLOXHSVRandomAug'),
  157. dict(type='RandomFlip', prob=0.5),
  158. dict(type='Resize', scale=(640, 640), keep_ratio=True),
  159. dict(
  160. type='Pad',
  161. pad_to_square=True,
  162. pad_val=dict(img=(114.0, 114.0, 114.0))),
  163. dict(
  164. type='FilterAnnotations', min_gt_bbox_wh=(1, 1), keep_empty=False),
  165. dict(type='PackDetInputs')
  166. ])
  167. test_pipeline = [
  168. dict(type='LoadImageFromFile', backend_args=dict(backend='local')),
  169. dict(type='Resize', scale=(640, 640), keep_ratio=True),
  170. dict(
  171. type='Pad',
  172. pad_to_square=True,
  173. pad_val=dict(img=(114.0, 114.0, 114.0))),
  174. dict(type='LoadAnnotations', with_bbox=True),
  175. dict(
  176. type='PackDetInputs',
  177. meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
  178. 'scale_factor'))
  179. ]
  180. train_dataloader = dict(
  181. batch_size=8,
  182. num_workers=4,
  183. persistent_workers=True,
  184. sampler=dict(type='DefaultSampler', shuffle=True),
  185. dataset=dict(
  186. type='MultiImageMixDataset',
  187. dataset=dict(
  188. type='CocoDataset',
  189. data_root='data/coco/',
  190. ann_file='annotations/coco_face_train.json',
  191. data_prefix=dict(img='train2017/'),
  192. pipeline=[
  193. dict(
  194. type='LoadImageFromFile',
  195. backend_args=dict(backend='local')),
  196. dict(type='LoadAnnotations', with_bbox=True)
  197. ],
  198. filter_cfg=dict(filter_empty_gt=False, min_size=32),
  199. metainfo=dict(CLASSES=('person', ), PALETTE=(220, 20, 60))),
  200. pipeline=[
  201. dict(type='Mosaic', img_scale=(640, 640), pad_val=114.0),
  202. dict(
  203. type='RandomAffine',
  204. scaling_ratio_range=(0.1, 2),
  205. border=(-320, -320)),
  206. dict(
  207. type='MixUp',
  208. img_scale=(640, 640),
  209. ratio_range=(0.8, 1.6),
  210. pad_val=114.0),
  211. dict(type='YOLOXHSVRandomAug'),
  212. dict(type='RandomFlip', prob=0.5),
  213. dict(type='Resize', scale=(640, 640), keep_ratio=True),
  214. dict(
  215. type='Pad',
  216. pad_to_square=True,
  217. pad_val=dict(img=(114.0, 114.0, 114.0))),
  218. dict(
  219. type='FilterAnnotations',
  220. min_gt_bbox_wh=(1, 1),
  221. keep_empty=False),
  222. dict(type='PackDetInputs')
  223. ]))
  224. val_dataloader = dict(
  225. batch_size=8,
  226. num_workers=4,
  227. persistent_workers=True,
  228. drop_last=False,
  229. sampler=dict(type='DefaultSampler', shuffle=False),
  230. dataset=dict(
  231. type='CocoDataset',
  232. data_root='data/coco/',
  233. ann_file='annotations/coco_face_val.json',
  234. data_prefix=dict(img='val2017/'),
  235. test_mode=True,
  236. pipeline=[
  237. dict(type='LoadImageFromFile', backend_args=dict(backend='local')),
  238. dict(type='Resize', scale=(640, 640), keep_ratio=True),
  239. dict(
  240. type='Pad',
  241. pad_to_square=True,
  242. pad_val=dict(img=(114.0, 114.0, 114.0))),
  243. dict(type='LoadAnnotations', with_bbox=True),
  244. dict(
  245. type='PackDetInputs',
  246. meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
  247. 'scale_factor'))
  248. ],
  249. metainfo=dict(CLASSES=('person', ), PALETTE=(220, 20, 60))))
  250. test_dataloader = dict(
  251. batch_size=8,
  252. num_workers=4,
  253. persistent_workers=True,
  254. drop_last=False,
  255. sampler=dict(type='DefaultSampler', shuffle=False),
  256. dataset=dict(
  257. type='CocoDataset',
  258. data_root='data/coco/',
  259. ann_file='annotations/coco_face_val.json',
  260. data_prefix=dict(img='val2017/'),
  261. test_mode=True,
  262. pipeline=[
  263. dict(type='LoadImageFromFile', backend_args=dict(backend='local')),
  264. dict(type='Resize', scale=(640, 640), keep_ratio=True),
  265. dict(
  266. type='Pad',
  267. pad_to_square=True,
  268. pad_val=dict(img=(114.0, 114.0, 114.0))),
  269. dict(type='LoadAnnotations', with_bbox=True),
  270. dict(
  271. type='PackDetInputs',
  272. meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
  273. 'scale_factor'))
  274. ],
  275. metainfo=dict(CLASSES=('person', ), PALETTE=(220, 20, 60))))
  276. val_evaluator = dict(
  277. type='CocoMetric',
  278. ann_file='data/coco/annotations/coco_face_val.json',
  279. metric='bbox')
  280. test_evaluator = dict(
  281. type='CocoMetric',
  282. ann_file='data/coco/annotations/instances_val2017.json',
  283. metric='bbox')
  284. max_epochs = 300
  285. num_last_epochs = 15
  286. interval = 10
  287. base_lr = 0.01
  288. custom_hooks = [
  289. dict(type='YOLOXModeSwitchHook', num_last_epochs=15, priority=48),
  290. dict(type='SyncNormHook', priority=48),
  291. dict(
  292. type='EMAHook',
  293. ema_type='ExpMomentumEMA',
  294. momentum=0.0001,
  295. strict_load=False,
  296. update_buffers=True,
  297. priority=49)
  298. ]
  299. metainfo = dict(CLASSES=('person', ), PALETTE=(220, 20, 60))
  300. launcher = 'pytorch'