config_rtmdet.py 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. auto_scale_lr = dict(base_batch_size=12, enable=False)
  2. backend_args = None
  3. base_lr = 0.001
  4. checkpoint = 'https://download.openmmlab.com/mmdetection/v3.0/rtmdet/cspnext_rsb_pretrain/cspnext-s_imagenet_600e.pth'
  5. custom_hooks = [
  6. dict(
  7. ema_type='ExpMomentumEMA',
  8. momentum=0.0002,
  9. priority=49,
  10. type='EMAHook',
  11. update_buffers=True),
  12. dict(
  13. switch_epoch=280,
  14. switch_pipeline=[
  15. dict(backend_args=None, type='LoadImageFromFile'),
  16. dict(type='LoadAnnotations', with_bbox=True),
  17. dict(
  18. keep_ratio=True,
  19. ratio_range=(
  20. 0.5,
  21. 2.0,
  22. ),
  23. scale=(
  24. 640,
  25. 640,
  26. ),
  27. type='RandomResize'),
  28. dict(crop_size=(
  29. 640,
  30. 640,
  31. ), type='RandomCrop'),
  32. dict(type='YOLOXHSVRandomAug'),
  33. dict(prob=0.5, type='RandomFlip'),
  34. dict(
  35. pad_val=dict(img=(
  36. 114,
  37. 114,
  38. 114,
  39. )),
  40. size=(
  41. 640,
  42. 640,
  43. ),
  44. type='Pad'),
  45. dict(type='PackDetInputs'),
  46. ],
  47. type='PipelineSwitchHook'),
  48. ]
  49. data_root = '../../../media/tricolops/T7/Dataset/coco_format_bd/'
  50. dataset_type = 'CocoDataset'
  51. default_hooks = dict(
  52. checkpoint=dict(interval=5, save_best='auto', type='CheckpointHook'),
  53. logger=dict(interval=50, type='LoggerHook'),
  54. param_scheduler=dict(type='ParamSchedulerHook'),
  55. sampler_seed=dict(type='DistSamplerSeedHook'),
  56. timer=dict(type='IterTimerHook'),
  57. visualization=dict(
  58. draw=True, test_out_dir='res', type='DetVisualizationHook'))
  59. default_scope = 'mmdet'
  60. env_cfg = dict(
  61. cudnn_benchmark=False,
  62. dist_cfg=dict(backend='nccl'),
  63. mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0))
  64. img_scales = [
  65. (
  66. 640,
  67. 640,
  68. ),
  69. (
  70. 320,
  71. 320,
  72. ),
  73. (
  74. 960,
  75. 960,
  76. ),
  77. ]
  78. interval = 5
  79. launcher = 'none'
  80. load_from = 'work_dirs/rtmdet_small_1xb16-300e_coco/best_coco_bbox_mAP_epoch_272.pth'
  81. log_level = 'INFO'
  82. log_processor = dict(by_epoch=True, type='LogProcessor', window_size=50)
  83. max_epochs = 300
  84. metainfo = dict(
  85. classes=('barcode', ), palette=[
  86. (
  87. 220,
  88. 20,
  89. 60,
  90. ),
  91. ])
  92. model = dict(
  93. backbone=dict(
  94. act_cfg=dict(inplace=True, type='SiLU'),
  95. arch='P5',
  96. channel_attention=True,
  97. deepen_factor=0.33,
  98. expand_ratio=0.5,
  99. init_cfg=dict(
  100. checkpoint=
  101. 'https://download.openmmlab.com/mmdetection/v3.0/rtmdet/cspnext_rsb_pretrain/cspnext-s_imagenet_600e.pth',
  102. prefix='backbone.',
  103. type='Pretrained'),
  104. norm_cfg=dict(type='SyncBN'),
  105. type='CSPNeXt',
  106. widen_factor=0.5),
  107. bbox_head=dict(
  108. act_cfg=dict(inplace=True, type='SiLU'),
  109. anchor_generator=dict(
  110. offset=0, strides=[
  111. 8,
  112. 16,
  113. 32,
  114. ], type='MlvlPointGenerator'),
  115. bbox_coder=dict(type='DistancePointBBoxCoder'),
  116. exp_on_reg=False,
  117. feat_channels=128,
  118. in_channels=128,
  119. loss_bbox=dict(loss_weight=2.0, type='SIoULoss'),
  120. loss_cls=dict(
  121. beta=2.0,
  122. loss_weight=1.0,
  123. type='QualityFocalLoss',
  124. use_sigmoid=True),
  125. norm_cfg=dict(type='SyncBN'),
  126. num_classes=1,
  127. pred_kernel_size=1,
  128. share_conv=True,
  129. stacked_convs=2,
  130. type='RTMDetSepBNHead',
  131. with_objectness=False),
  132. data_preprocessor=dict(
  133. batch_augments=None,
  134. bgr_to_rgb=False,
  135. mean=[
  136. 103.53,
  137. 116.28,
  138. 123.675,
  139. ],
  140. std=[
  141. 57.375,
  142. 57.12,
  143. 58.395,
  144. ],
  145. type='DetDataPreprocessor'),
  146. neck=dict(
  147. act_cfg=dict(inplace=True, type='SiLU'),
  148. expand_ratio=0.5,
  149. in_channels=[
  150. 128,
  151. 256,
  152. 512,
  153. ],
  154. norm_cfg=dict(type='SyncBN'),
  155. num_csp_blocks=1,
  156. out_channels=128,
  157. type='CSPNeXtPAFPN'),
  158. test_cfg=dict(
  159. max_per_img=300,
  160. min_bbox_size=0,
  161. nms=dict(iou_threshold=0.65, type='nms'),
  162. nms_pre=30000,
  163. score_thr=0.001),
  164. train_cfg=dict(
  165. allowed_border=-1,
  166. assigner=dict(topk=13, type='DynamicSoftLabelAssigner'),
  167. debug=False,
  168. pos_weight=-1),
  169. type='RTMDet')
  170. optim_wrapper = dict(
  171. clip_grad=dict(max_norm=0.1, norm_type=2),
  172. optimizer=dict(lr=0.001, type='AdamW', weight_decay=0.05),
  173. paramwise_cfg=dict(
  174. bias_decay_mult=0, bypass_duplicate=True, norm_decay_mult=0),
  175. type='OptimWrapper')
  176. param_scheduler = [
  177. dict(
  178. begin=0, by_epoch=False, end=1000, start_factor=1e-05,
  179. type='LinearLR'),
  180. dict(
  181. T_max=150,
  182. begin=150,
  183. by_epoch=True,
  184. convert_to_iter_based=True,
  185. end=300,
  186. eta_min=5e-05,
  187. type='CosineAnnealingLR'),
  188. ]
  189. resume = False
  190. test_cfg = dict(type='TestLoop')
  191. test_dataloader = dict(
  192. batch_size=1,
  193. dataset=dict(
  194. ann_file='Val/Val.json',
  195. backend_args=None,
  196. data_prefix=dict(img='Val/'),
  197. data_root='../../../media/tricolops/T7/Dataset/coco_format_bd/',
  198. metainfo=dict(classes=('barcode', ), palette=[
  199. (
  200. 220,
  201. 20,
  202. 60,
  203. ),
  204. ]),
  205. pipeline=[
  206. dict(backend_args=None, type='LoadImageFromFile'),
  207. dict(keep_ratio=True, scale=(
  208. 640,
  209. 640,
  210. ), type='Resize'),
  211. dict(
  212. pad_val=dict(img=(
  213. 114,
  214. 114,
  215. 114,
  216. )),
  217. size=(
  218. 640,
  219. 640,
  220. ),
  221. type='Pad'),
  222. dict(type='LoadAnnotations', with_bbox=True),
  223. dict(
  224. meta_keys=(
  225. 'img_id',
  226. 'img_path',
  227. 'ori_shape',
  228. 'img_shape',
  229. 'scale_factor',
  230. ),
  231. type='PackDetInputs'),
  232. ],
  233. test_mode=True,
  234. type='CocoDataset'),
  235. drop_last=False,
  236. num_workers=10,
  237. persistent_workers=True,
  238. sampler=dict(shuffle=False, type='DefaultSampler'))
  239. test_evaluator = dict(
  240. ann_file='../../../media/tricolops/T7/Dataset/coco_format_bd/Val/Val.json',
  241. backend_args=None,
  242. format_only=False,
  243. metric='bbox',
  244. proposal_nums=(
  245. 100,
  246. 1,
  247. 10,
  248. ),
  249. type='CocoMetric')
  250. test_pipeline = [
  251. dict(backend_args=None, type='LoadImageFromFile'),
  252. dict(keep_ratio=True, scale=(
  253. 640,
  254. 640,
  255. ), type='Resize'),
  256. dict(pad_val=dict(img=(
  257. 114,
  258. 114,
  259. 114,
  260. )), size=(
  261. 640,
  262. 640,
  263. ), type='Pad'),
  264. dict(type='LoadAnnotations', with_bbox=True),
  265. dict(
  266. meta_keys=(
  267. 'img_id',
  268. 'img_path',
  269. 'ori_shape',
  270. 'img_shape',
  271. 'scale_factor',
  272. ),
  273. type='PackDetInputs'),
  274. ]
  275. train_cfg = dict(
  276. dynamic_intervals=[
  277. (
  278. 220,
  279. 1,
  280. ),
  281. ],
  282. max_epochs=300,
  283. type='EpochBasedTrainLoop',
  284. val_interval=5)
  285. train_dataloader = dict(
  286. batch_sampler=None,
  287. batch_size=12,
  288. dataset=dict(
  289. ann_file='Train/Train.json',
  290. backend_args=None,
  291. data_prefix=dict(img='Train/'),
  292. data_root='../../../media/tricolops/T7/Dataset/coco_format_bd/',
  293. filter_cfg=dict(filter_empty_gt=True, min_size=32),
  294. metainfo=dict(classes=('barcode', ), palette=[
  295. (
  296. 220,
  297. 20,
  298. 60,
  299. ),
  300. ]),
  301. pipeline=[
  302. dict(backend_args=None, type='LoadImageFromFile'),
  303. dict(type='LoadAnnotations', with_bbox=True),
  304. dict(
  305. img_scale=(
  306. 640,
  307. 640,
  308. ),
  309. max_cached_images=20,
  310. pad_val=114.0,
  311. random_pop=False,
  312. type='CachedMosaic'),
  313. dict(
  314. keep_ratio=True,
  315. ratio_range=(
  316. 0.5,
  317. 2.0,
  318. ),
  319. scale=(
  320. 640,
  321. 640,
  322. ),
  323. type='RandomResize'),
  324. dict(crop_size=(
  325. 640,
  326. 640,
  327. ), type='RandomCrop'),
  328. dict(type='YOLOXHSVRandomAug'),
  329. dict(prob=0.5, type='RandomFlip'),
  330. dict(
  331. pad_val=dict(img=(
  332. 114,
  333. 114,
  334. 114,
  335. )),
  336. size=(
  337. 640,
  338. 640,
  339. ),
  340. type='Pad'),
  341. dict(
  342. img_scale=(
  343. 640,
  344. 640,
  345. ),
  346. max_cached_images=10,
  347. pad_val=(
  348. 114,
  349. 114,
  350. 114,
  351. ),
  352. prob=0.5,
  353. random_pop=False,
  354. ratio_range=(
  355. 1.0,
  356. 1.0,
  357. ),
  358. type='CachedMixUp'),
  359. dict(type='PackDetInputs'),
  360. ],
  361. type='CocoDataset'),
  362. num_workers=10,
  363. persistent_workers=True,
  364. pin_memory=True,
  365. sampler=dict(shuffle=True, type='DefaultSampler'))
  366. tta_model = dict(
  367. tta_cfg=dict(max_per_img=100, nms=dict(iou_threshold=0.6, type='nms')),
  368. type='DetTTAModel')
  369. tta_pipeline = [
  370. dict(backend_args=None, type='LoadImageFromFile'),
  371. dict(
  372. transforms=[
  373. [
  374. dict(keep_ratio=True, scale=(
  375. 640,
  376. 640,
  377. ), type='Resize'),
  378. dict(keep_ratio=True, scale=(
  379. 320,
  380. 320,
  381. ), type='Resize'),
  382. dict(keep_ratio=True, scale=(
  383. 960,
  384. 960,
  385. ), type='Resize'),
  386. ],
  387. [
  388. dict(prob=1.0, type='RandomFlip'),
  389. dict(prob=0.0, type='RandomFlip'),
  390. ],
  391. [
  392. dict(
  393. pad_val=dict(img=(
  394. 114,
  395. 114,
  396. 114,
  397. )),
  398. size=(
  399. 960,
  400. 960,
  401. ),
  402. type='Pad'),
  403. ],
  404. [
  405. dict(type='LoadAnnotations', with_bbox=True),
  406. ],
  407. [
  408. dict(
  409. meta_keys=(
  410. 'img_id',
  411. 'img_path',
  412. 'ori_shape',
  413. 'img_shape',
  414. 'scale_factor',
  415. 'flip',
  416. 'flip_direction',
  417. ),
  418. type='PackDetInputs'),
  419. ],
  420. ],
  421. type='TestTimeAug'),
  422. ]
  423. val_cfg = dict(type='ValLoop')
  424. val_dataloader = dict(
  425. batch_size=1,
  426. dataset=dict(
  427. ann_file='Val/Val.json',
  428. backend_args=None,
  429. data_prefix=dict(img='Val/'),
  430. data_root='../../../media/tricolops/T7/Dataset/coco_format_bd/',
  431. metainfo=dict(classes=('barcode', ), palette=[
  432. (
  433. 220,
  434. 20,
  435. 60,
  436. ),
  437. ]),
  438. pipeline=[
  439. dict(backend_args=None, type='LoadImageFromFile'),
  440. dict(keep_ratio=True, scale=(
  441. 640,
  442. 640,
  443. ), type='Resize'),
  444. dict(
  445. pad_val=dict(img=(
  446. 114,
  447. 114,
  448. 114,
  449. )),
  450. size=(
  451. 640,
  452. 640,
  453. ),
  454. type='Pad'),
  455. dict(type='LoadAnnotations', with_bbox=True),
  456. dict(
  457. meta_keys=(
  458. 'img_id',
  459. 'img_path',
  460. 'ori_shape',
  461. 'img_shape',
  462. 'scale_factor',
  463. ),
  464. type='PackDetInputs'),
  465. ],
  466. test_mode=True,
  467. type='CocoDataset'),
  468. drop_last=False,
  469. num_workers=10,
  470. persistent_workers=True,
  471. sampler=dict(shuffle=False, type='DefaultSampler'))
  472. val_evaluator = dict(
  473. ann_file='../../../media/tricolops/T7/Dataset/coco_format_bd/Val/Val.json',
  474. backend_args=None,
  475. format_only=False,
  476. metric='bbox',
  477. proposal_nums=(
  478. 100,
  479. 1,
  480. 10,
  481. ),
  482. type='CocoMetric')
  483. vis_backends = [
  484. dict(type='LocalVisBackend'),
  485. ]
  486. visualizer = dict(
  487. name='visualizer',
  488. type='DetLocalVisualizer',
  489. vis_backends=[
  490. dict(type='LocalVisBackend'),
  491. ])
  492. work_dir = 'result/'