Co-DINO-Swin-L.yaml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. # Runtime
  2. find_unused_parameters: True
  3. use_gpu: true
  4. use_xpu: false
  5. use_mlu: false
  6. use_npu: false
  7. log_iter: 20
  8. save_dir: output
  9. snapshot_epoch: 1
  10. print_flops: false
  11. print_params: false
  12. use_ema: true
  13. # Dataset
  14. metric: COCO
  15. num_classes: 80
  16. TrainDataset:
  17. name: COCODataSet
  18. image_dir: train2017
  19. anno_path: annotations/instances_train2017.json
  20. dataset_dir: dataset/coco
  21. allow_empty: true
  22. data_fields: ['image', 'gt_bbox', 'gt_class', 'is_crowd']
  23. EvalDataset:
  24. name: COCODataSet
  25. image_dir: val2017
  26. anno_path: annotations/instances_val2017.json
  27. dataset_dir: dataset/coco
  28. allow_empty: true
  29. TestDataset:
  30. name: ImageFolder
  31. anno_path: annotations/instances_val2017.json # also support txt (like VOC's label_list.txt)
  32. dataset_dir: dataset/coco # if set, anno_path will be 'dataset_dir/anno_path'
  33. # Reader
  34. worker_num: 1
  35. TrainReader:
  36. sample_transforms:
  37. - Decode: {}
  38. - RandomFlip: {prob: 0.5}
  39. - RandomSelect: { transforms1: [ RandomShortSideResize: { short_side_sizes: [ 480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800 ], max_size: 1333 } ],
  40. transforms2: [
  41. RandomShortSideResize: { short_side_sizes: [ 400, 500, 600 ] },
  42. RandomSizeCrop: { min_size: 384, max_size: 600 },
  43. RandomShortSideResize: { short_side_sizes: [ 480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800 ], max_size: 1333 } ]
  44. }
  45. - NormalizeImage: {is_scale: true, mean: [0.485,0.456,0.406], std: [0.229, 0.224,0.225]}
  46. - Permute: {}
  47. batch_transforms:
  48. - PadMaskBatch: {pad_to_stride: -1, return_pad_mask: true}
  49. batch_size: 1
  50. shuffle: true
  51. drop_last: true
  52. collate_batch: false
  53. use_shared_memory: false
  54. EvalReader:
  55. sample_transforms:
  56. - Decode: {}
  57. - Resize: {target_size: [800, 1333], keep_ratio: True}
  58. - NormalizeImage: {is_scale: true, mean: [0.485,0.456,0.406], std: [0.229, 0.224,0.225]}
  59. - Permute: {}
  60. batch_size: 1
  61. shuffle: false
  62. drop_last: false
  63. TestReader:
  64. inputs_def:
  65. image_shape: [-1, 3, 640, 640]
  66. sample_transforms:
  67. - Decode: {}
  68. - Resize: {target_size: 640, keep_ratio: false}
  69. - NormalizeImage: {is_scale: true, mean: [0.485,0.456,0.406], std: [0.229, 0.224,0.225]}
  70. - Permute: {}
  71. batch_size: 1
  72. shuffle: false
  73. drop_last: false
  74. # Model
  75. architecture: CO_DETR
  76. pretrain_weights: https://bj.bcebos.com/v1/paddledet/models/pretrained/swin_large_patch4_window12_384_22kto1k_pretrained.pdparams
  77. num_dec_layer: &num_dec_layer 6
  78. CO_DETR:
  79. backbone: SwinTransformer
  80. backbone_lr_mult: 0.1
  81. neck: ChannelMapper
  82. query_head: CoDINOHead
  83. rpn_head: RPNHead
  84. roi_head: Co_RoiHead
  85. bbox_head:
  86. name: CoATSSHead
  87. in_channels: 256
  88. stacked_convs: 1
  89. feat_channels: 256
  90. bbox_weight: [10., 10., 5., 5.]
  91. anchor_generator:
  92. name: CoAnchorGenerator
  93. octave_base_scale: 8
  94. scales_per_octave: 1
  95. aspect_ratios: [1.0]
  96. strides: [4., 8., 16., 32., 64., 128.]
  97. assigner:
  98. name: ATSSAssigner
  99. topk: 9
  100. sm_use: True
  101. loss_cls:
  102. name: Weighted_FocalLoss
  103. use_sigmoid: true
  104. gamma: 2.0
  105. alpha: 0.25
  106. loss_weight: 12.0
  107. loss_bbox:
  108. name: GIoULoss
  109. loss_weight: 24.0
  110. reduction: sum
  111. loss_cent_weight: 12.0
  112. SwinTransformer:
  113. arch: 'swin_L_384' # ['swin_T_224', 'swin_S_224', 'swin_B_224', 'swin_L_224', 'swin_B_384', 'swin_L_384']
  114. out_indices: [0, 1, 2, 3]
  115. ape: false
  116. drop_path_rate: 0.3
  117. patch_norm: true
  118. ChannelMapper:
  119. in_channels: [192, 384, 768, 1536]
  120. kernel_size: 1
  121. out_channels: 256
  122. norm_type: "gn"
  123. norm_groups: 32
  124. act: None
  125. num_outs: 5
  126. strides: [4., 8., 16., 32., 64.]
  127. CoDINOHead:
  128. num_query: 900
  129. num_dn_query: 100
  130. label_noise_ratio: 0.5
  131. box_noise_scale: 1.0
  132. in_channels: 2048
  133. sync_cls_avg_factor: True
  134. with_box_refine: True
  135. as_two_stage: True
  136. mixed_selection: True
  137. transformer:
  138. name: CoDINOTransformer
  139. two_stage_num_proposals: 900
  140. with_pos_coord: True
  141. with_coord_feat: False
  142. num_co_heads: 2
  143. num_feature_levels: 5
  144. as_two_stage: True
  145. mixed_selection: True
  146. embed_dims: &embed_dims 256
  147. encoder:
  148. name: DeformableTransformerEncoder
  149. num_layers: *num_dec_layer
  150. with_rp: 6
  151. encoder_layer:
  152. name: DeformableTransformerEncoderLayer
  153. d_model: *embed_dims
  154. n_head: 8
  155. dim_feedforward: 2048
  156. n_levels: 5
  157. n_points: 4
  158. dropout: 0.0
  159. decoder:
  160. name: DINOTransformerDecoder
  161. hidden_dim: *embed_dims
  162. num_layers: *num_dec_layer
  163. decoder_layer:
  164. name: DINOTransformerDecoderLayer
  165. d_model: *embed_dims
  166. n_head: 8
  167. dim_feedforward: 2048
  168. n_points: 4
  169. n_levels: 5
  170. dropout: 0.0
  171. positional_encoding:
  172. name: PositionEmbedding
  173. num_pos_feats: 128
  174. temperature: 20
  175. normalize: true
  176. loss_cls:
  177. name: QualityFocalLoss
  178. use_sigmoid: true
  179. beta: 2.0
  180. loss_weight: 1.0
  181. loss_bbox:
  182. name: L1Loss
  183. loss_weight: 5.0
  184. loss_iou:
  185. name: GIoULoss
  186. loss_weight: 2.0
  187. reduction: sum
  188. assigner:
  189. name: HungarianAssigner
  190. cls_cost:
  191. name: FocalLossCost
  192. weight: 2.0
  193. reg_cost:
  194. name: BBoxL1Cost
  195. weight: 5.0
  196. box_format: xywh
  197. iou_cost:
  198. name: IoUCost
  199. iou_mode: giou
  200. weight: 2.0
  201. test_cfg:
  202. max_per_img: 300
  203. score_thr: 0.0
  204. nms:
  205. name: MultiClassNMS
  206. keep_top_k: -1
  207. score_threshold: 0.0
  208. nms_threshold: 0.8
  209. RPNHead:
  210. loss_rpn_bbox:
  211. name: L1Loss
  212. reduction: sum
  213. loss_weight: 12.0
  214. in_channel: 256
  215. anchor_generator:
  216. name: RetinaAnchorGenerator
  217. octave_base_scale: 4
  218. scales_per_octave: 3
  219. aspect_ratios: [0.5, 1.0, 2.0]
  220. strides: [4., 8., 16., 32., 64., 128.]
  221. rpn_target_assign:
  222. batch_size_per_im: 256
  223. fg_fraction: 0.5
  224. negative_overlap: 0.3
  225. positive_overlap: 0.7
  226. use_random: True
  227. train_proposal:
  228. min_size: 0.0
  229. nms_thresh: 0.7
  230. pre_nms_top_n: 4000
  231. post_nms_top_n: 1000
  232. topk_after_collect: True
  233. test_proposal:
  234. min_size: 0.0
  235. nms_thresh: 0.7
  236. pre_nms_top_n: 1000
  237. post_nms_top_n: 1000
  238. Co_RoiHead:
  239. in_channel: 256
  240. loss_normalize_pos: True
  241. head: TwoFCHead
  242. roi_extractor:
  243. end_level: 4
  244. resolution: 7
  245. sampling_ratio: 0
  246. aligned: True
  247. bbox_assigner:
  248. name: BBoxAssigner
  249. batch_size_per_im: 512
  250. bg_thresh: 0.5
  251. fg_thresh: 0.5
  252. fg_fraction: 0.25
  253. use_random: True
  254. bbox_loss:
  255. name: GIoULoss
  256. loss_weight: 120.0
  257. cls_loss_weight: 12.0
  258. # Optimizer
  259. epoch: 12
  260. LearningRate:
  261. base_lr: 0.0001
  262. schedulers:
  263. - !PiecewiseDecay
  264. gamma: 0.1
  265. milestones: [11]
  266. use_warmup: false
  267. OptimizerBuilder:
  268. clip_grad_by_norm: 0.1
  269. regularizer: false
  270. optimizer:
  271. type: AdamW
  272. weight_decay: 0.0001
  273. # Exporting the model
  274. export:
  275. post_process: True # Whether post-processing is included in the network when export model.
  276. nms: True # Whether NMS is included in the network when export model.
  277. benchmark: False # It is used to testing model performance, if set `True`, post-process and NMS will not be exported.
  278. fuse_conv_bn: False