config.py 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. auto_scale_lr = dict(base_batch_size=32)
  2. backend_args = None
  3. data_root = '../../../media/tricolops/T7/Dataset/coco_format_bd/'
  4. dataset_type = 'CocoDataset'
  5. default_hooks = dict(
  6. checkpoint=dict(interval=10, type='CheckpointHook'),
  7. logger=dict(interval=50, type='LoggerHook'),
  8. param_scheduler=dict(type='ParamSchedulerHook'),
  9. sampler_seed=dict(type='DistSamplerSeedHook'),
  10. timer=dict(type='IterTimerHook'),
  11. visualization=dict(
  12. draw=True, test_out_dir='res', type='DetVisualizationHook'))
  13. default_scope = 'mmdet'
  14. env_cfg = dict(
  15. cudnn_benchmark=False,
  16. dist_cfg=dict(backend='nccl'),
  17. mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0))
  18. launcher = 'none'
  19. load_from = 'work_dirs/deformable-detr_r50_16xb2-50e_coco/epoch_470.pth'
  20. log_level = 'INFO'
  21. log_processor = dict(by_epoch=True, type='LogProcessor', window_size=50)
  22. max_epochs = 500
  23. metainfo = dict(
  24. classes=('barcode', ), palette=[
  25. (
  26. 220,
  27. 20,
  28. 60,
  29. ),
  30. ])
  31. model = dict(
  32. as_two_stage=False,
  33. backbone=dict(
  34. depth=50,
  35. frozen_stages=1,
  36. init_cfg=dict(checkpoint='torchvision://resnet50', type='Pretrained'),
  37. norm_cfg=dict(requires_grad=False, type='BN'),
  38. norm_eval=True,
  39. num_stages=4,
  40. out_indices=(
  41. 1,
  42. 2,
  43. 3,
  44. ),
  45. style='pytorch',
  46. type='ResNet'),
  47. bbox_head=dict(
  48. loss_bbox=dict(loss_weight=5.0, type='L1Loss'),
  49. loss_cls=dict(
  50. alpha=0.25,
  51. gamma=2.0,
  52. loss_weight=2.0,
  53. type='FocalLoss',
  54. use_sigmoid=True),
  55. loss_iou=dict(loss_weight=2.0, type='GIoULoss'),
  56. num_classes=1,
  57. sync_cls_avg_factor=True,
  58. type='DeformableDETRHead'),
  59. data_preprocessor=dict(
  60. bgr_to_rgb=True,
  61. mean=[
  62. 123.675,
  63. 116.28,
  64. 103.53,
  65. ],
  66. pad_size_divisor=1,
  67. std=[
  68. 58.395,
  69. 57.12,
  70. 57.375,
  71. ],
  72. type='DetDataPreprocessor'),
  73. decoder=dict(
  74. layer_cfg=dict(
  75. cross_attn_cfg=dict(batch_first=True, embed_dims=256),
  76. ffn_cfg=dict(
  77. embed_dims=256, feedforward_channels=1024, ffn_drop=0.1),
  78. self_attn_cfg=dict(
  79. batch_first=True, dropout=0.1, embed_dims=256, num_heads=8)),
  80. num_layers=6,
  81. post_norm_cfg=None,
  82. return_intermediate=True),
  83. encoder=dict(
  84. layer_cfg=dict(
  85. ffn_cfg=dict(
  86. embed_dims=256, feedforward_channels=1024, ffn_drop=0.1),
  87. self_attn_cfg=dict(batch_first=True, embed_dims=256)),
  88. num_layers=6),
  89. neck=dict(
  90. act_cfg=None,
  91. in_channels=[
  92. 512,
  93. 1024,
  94. 2048,
  95. ],
  96. kernel_size=1,
  97. norm_cfg=dict(num_groups=32, type='GN'),
  98. num_outs=4,
  99. out_channels=256,
  100. type='ChannelMapper'),
  101. num_feature_levels=4,
  102. num_queries=300,
  103. positional_encoding=dict(normalize=True, num_feats=128, offset=-0.5),
  104. test_cfg=dict(max_per_img=100),
  105. train_cfg=dict(
  106. assigner=dict(
  107. match_costs=[
  108. dict(type='FocalLossCost', weight=2.0),
  109. dict(box_format='xywh', type='BBoxL1Cost', weight=5.0),
  110. dict(iou_mode='giou', type='IoUCost', weight=2.0),
  111. ],
  112. type='HungarianAssigner')),
  113. type='DeformableDETR',
  114. with_box_refine=False)
  115. optim_wrapper = dict(
  116. clip_grad=dict(max_norm=10, norm_type=2),
  117. optimizer=dict(lr=0.0002, type='AdamW', weight_decay=0.0001),
  118. paramwise_cfg=dict(
  119. custom_keys=dict(
  120. backbone=dict(lr_mult=0.1),
  121. reference_points=dict(lr_mult=0.1),
  122. sampling_offsets=dict(lr_mult=0.1))),
  123. type='OptimWrapper')
  124. param_scheduler = [
  125. dict(
  126. begin=0,
  127. by_epoch=True,
  128. end=500,
  129. gamma=0.1,
  130. milestones=[
  131. 40,
  132. ],
  133. type='MultiStepLR'),
  134. ]
  135. resume = False
  136. test_cfg = dict(type='TestLoop')
  137. test_dataloader = dict(
  138. batch_size=1,
  139. dataset=dict(
  140. ann_file='Val/Val.json',
  141. backend_args=None,
  142. data_prefix=dict(img='Val/'),
  143. data_root='../../../media/tricolops/T7/Dataset/coco_format_bd/',
  144. metainfo=dict(classes=('barcode', ), palette=[
  145. (
  146. 220,
  147. 20,
  148. 60,
  149. ),
  150. ]),
  151. pipeline=[
  152. dict(backend_args=None, type='LoadImageFromFile'),
  153. dict(keep_ratio=True, scale=(
  154. 640,
  155. 640,
  156. ), type='Resize'),
  157. dict(type='LoadAnnotations', with_bbox=True),
  158. dict(
  159. meta_keys=(
  160. 'img_id',
  161. 'img_path',
  162. 'ori_shape',
  163. 'img_shape',
  164. 'scale_factor',
  165. ),
  166. type='PackDetInputs'),
  167. ],
  168. test_mode=True,
  169. type='CocoDataset'),
  170. drop_last=False,
  171. num_workers=2,
  172. persistent_workers=True,
  173. sampler=dict(shuffle=False, type='DefaultSampler'))
  174. test_evaluator = dict(
  175. ann_file='../../../media/tricolops/T7/Dataset/coco_format_bd/Val/Val.json',
  176. backend_args=None,
  177. format_only=False,
  178. metric='bbox',
  179. type='CocoMetric')
  180. test_pipeline = [
  181. dict(backend_args=None, type='LoadImageFromFile'),
  182. dict(keep_ratio=True, scale=(
  183. 640,
  184. 640,
  185. ), type='Resize'),
  186. dict(type='LoadAnnotations', with_bbox=True),
  187. dict(
  188. meta_keys=(
  189. 'img_id',
  190. 'img_path',
  191. 'ori_shape',
  192. 'img_shape',
  193. 'scale_factor',
  194. ),
  195. type='PackDetInputs'),
  196. ]
  197. train_cfg = dict(max_epochs=500, type='EpochBasedTrainLoop', val_interval=10)
  198. train_dataloader = dict(
  199. batch_sampler=dict(type='AspectRatioBatchSampler'),
  200. batch_size=4,
  201. dataset=dict(
  202. ann_file='Train/Train.json',
  203. backend_args=None,
  204. data_prefix=dict(img='Train/'),
  205. data_root='../../../media/tricolops/T7/Dataset/coco_format_bd/',
  206. filter_cfg=dict(filter_empty_gt=False, min_size=32),
  207. metainfo=dict(classes=('barcode', ), palette=[
  208. (
  209. 220,
  210. 20,
  211. 60,
  212. ),
  213. ]),
  214. pipeline=[
  215. dict(backend_args=None, type='LoadImageFromFile'),
  216. dict(type='LoadAnnotations', with_bbox=True),
  217. dict(prob=0.5, type='RandomFlip'),
  218. dict(
  219. keep_ratio=True,
  220. ratio_range=(
  221. 0.5,
  222. 2.0,
  223. ),
  224. scale=(
  225. 640,
  226. 640,
  227. ),
  228. type='RandomResize'),
  229. dict(crop_size=(
  230. 640,
  231. 640,
  232. ), type='RandomCrop'),
  233. dict(type='PackDetInputs'),
  234. ],
  235. type='CocoDataset'),
  236. num_workers=2,
  237. persistent_workers=True,
  238. sampler=dict(shuffle=True, type='DefaultSampler'))
  239. train_pipeline = [
  240. dict(backend_args=None, type='LoadImageFromFile'),
  241. dict(type='LoadAnnotations', with_bbox=True),
  242. dict(prob=0.5, type='RandomFlip'),
  243. dict(
  244. keep_ratio=True,
  245. ratio_range=(
  246. 0.5,
  247. 2.0,
  248. ),
  249. scale=(
  250. 640,
  251. 640,
  252. ),
  253. type='RandomResize'),
  254. dict(crop_size=(
  255. 640,
  256. 640,
  257. ), type='RandomCrop'),
  258. dict(type='PackDetInputs'),
  259. ]
  260. val_cfg = dict(type='ValLoop')
  261. val_dataloader = dict(
  262. batch_size=1,
  263. dataset=dict(
  264. ann_file='Val/Val.json',
  265. backend_args=None,
  266. data_prefix=dict(img='Val/'),
  267. data_root='../../../media/tricolops/T7/Dataset/coco_format_bd/',
  268. metainfo=dict(classes=('barcode', ), palette=[
  269. (
  270. 220,
  271. 20,
  272. 60,
  273. ),
  274. ]),
  275. pipeline=[
  276. dict(backend_args=None, type='LoadImageFromFile'),
  277. dict(keep_ratio=True, scale=(
  278. 640,
  279. 640,
  280. ), type='Resize'),
  281. dict(type='LoadAnnotations', with_bbox=True),
  282. dict(
  283. meta_keys=(
  284. 'img_id',
  285. 'img_path',
  286. 'ori_shape',
  287. 'img_shape',
  288. 'scale_factor',
  289. ),
  290. type='PackDetInputs'),
  291. ],
  292. test_mode=True,
  293. type='CocoDataset'),
  294. drop_last=False,
  295. num_workers=2,
  296. persistent_workers=True,
  297. sampler=dict(shuffle=False, type='DefaultSampler'))
  298. val_evaluator = dict(
  299. ann_file='../../../media/tricolops/T7/Dataset/coco_format_bd/Val/Val.json',
  300. backend_args=None,
  301. format_only=False,
  302. metric='bbox',
  303. type='CocoMetric')
  304. vis_backends = [
  305. dict(type='LocalVisBackend'),
  306. ]
  307. visualizer = dict(
  308. name='visualizer',
  309. type='DetLocalVisualizer',
  310. vis_backends=[
  311. dict(type='LocalVisBackend'),
  312. ])
  313. work_dir = 'result'