Co-Deformable-DETR-R50.yaml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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: 2
  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: 2
  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. sample_transforms:
  65. - Decode: {}
  66. - Resize: {target_size: [800, 1333], keep_ratio: True}
  67. - NormalizeImage: {is_scale: true, mean: [0.485,0.456,0.406], std: [0.229, 0.224,0.225]}
  68. - Permute: {}
  69. batch_size: 1
  70. shuffle: false
  71. drop_last: false
  72. # Model
  73. architecture: CO_DETR
  74. pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/ResNet50_cos_pretrained.pdparams
  75. num_dec_layer: &num_dec_layer 6
  76. CO_DETR:
  77. backbone: ResNet
  78. backbone_lr_mult: 0.1
  79. neck: ChannelMapper
  80. query_head: CoDeformDETRHead
  81. rpn_head: RPNHead
  82. roi_head: Co_RoiHead
  83. bbox_head:
  84. name: CoATSSHead
  85. in_channels: 256
  86. stacked_convs: 1
  87. feat_channels: 256
  88. bbox_weight: [10., 10., 5., 5.]
  89. anchor_generator:
  90. name: CoAnchorGenerator
  91. octave_base_scale: 8
  92. scales_per_octave: 1
  93. aspect_ratios: [1.0]
  94. strides: [8., 16., 32., 64., 128.]
  95. assigner:
  96. name: ATSSAssigner
  97. topk: 9
  98. sm_use: True
  99. loss_cls:
  100. name: Weighted_FocalLoss
  101. use_sigmoid: true
  102. gamma: 2.0
  103. alpha: 0.25
  104. loss_weight: 12.0
  105. loss_bbox:
  106. name: GIoULoss
  107. loss_weight: 24.0
  108. reduction: sum
  109. loss_cent_weight: 12.0
  110. ResNet:
  111. # index 0 stands for res2
  112. depth: 50
  113. norm_type: bn
  114. freeze_at: 0
  115. return_idx: [1, 2, 3]
  116. num_stages: 4
  117. ChannelMapper:
  118. in_channels: [512, 1024, 2048]
  119. kernel_size: 1
  120. out_channels: 256
  121. norm_type: "gn"
  122. norm_groups: 32
  123. act: None
  124. num_outs: 4
  125. strides: [8., 16., 32., 64.]
  126. CoDeformDETRHead:
  127. num_query: 300
  128. in_channels: 2048
  129. sync_cls_avg_factor: True
  130. with_box_refine: True
  131. as_two_stage: True
  132. mixed_selection: True
  133. transformer:
  134. name: CoDeformableDetrTransformer
  135. num_co_heads: 2
  136. as_two_stage: True
  137. mixed_selection: True
  138. embed_dims: &embed_dims 256
  139. encoder:
  140. name: DeformableTransformerEncoder
  141. num_layers: *num_dec_layer
  142. encoder_layer:
  143. name: DeformableTransformerEncoderLayer
  144. d_model: *embed_dims
  145. n_head: 8
  146. dim_feedforward: 2048
  147. n_levels: 4
  148. n_points: 4
  149. dropout: 0.0
  150. decoder:
  151. name: CoDeformableDetrTransformerDecoder
  152. num_layers: *num_dec_layer
  153. return_intermediate: True
  154. look_forward_twice: True
  155. decoder_layer:
  156. name: DeformableTransformerDecoderLayer
  157. d_model: *embed_dims
  158. dim_feedforward: 2048
  159. dropout: 0.0
  160. positional_encoding:
  161. name: PositionEmbedding
  162. num_pos_feats: 128
  163. normalize: true
  164. offset: -0.5
  165. loss_cls:
  166. name: Weighted_FocalLoss
  167. use_sigmoid: true
  168. gamma: 2.0
  169. alpha: 0.25
  170. loss_weight: 2.0
  171. loss_bbox:
  172. name: L1Loss
  173. loss_weight: 5.0
  174. loss_iou:
  175. name: GIoULoss
  176. loss_weight: 2.0
  177. reduction: sum
  178. assigner:
  179. name: HungarianAssigner
  180. cls_cost:
  181. name: FocalLossCost
  182. weight: 2.0
  183. reg_cost:
  184. name: BBoxL1Cost
  185. weight: 5.0
  186. box_format: xywh
  187. iou_cost:
  188. name: IoUCost
  189. iou_mode: giou
  190. weight: 2.0
  191. test_cfg:
  192. max_per_img: 100
  193. score_thr: 0.0
  194. RPNHead:
  195. loss_rpn_bbox:
  196. name: L1Loss
  197. reduction: sum
  198. loss_weight: 12.0
  199. in_channel: 256
  200. anchor_generator:
  201. name: RetinaAnchorGenerator
  202. octave_base_scale: 4
  203. scales_per_octave: 3
  204. aspect_ratios: [0.5, 1.0, 2.0]
  205. strides: [8.0, 16.0, 32.0, 64.0, 128.0]
  206. rpn_target_assign:
  207. batch_size_per_im: 256
  208. fg_fraction: 0.5
  209. negative_overlap: 0.3
  210. positive_overlap: 0.7
  211. use_random: True
  212. train_proposal:
  213. min_size: 0.0
  214. nms_thresh: 0.7
  215. pre_nms_top_n: 4000
  216. post_nms_top_n: 1000
  217. topk_after_collect: True
  218. test_proposal:
  219. min_size: 0.0
  220. nms_thresh: 0.7
  221. pre_nms_top_n: 1000
  222. post_nms_top_n: 1000
  223. Co_RoiHead:
  224. in_channel: 256
  225. loss_normalize_pos: True
  226. head: TwoFCHead
  227. roi_extractor:
  228. resolution: 7
  229. sampling_ratio: 0
  230. aligned: True
  231. bbox_assigner:
  232. name: BBoxAssigner
  233. batch_size_per_im: 512
  234. bg_thresh: 0.5
  235. fg_thresh: 0.5
  236. fg_fraction: 0.25
  237. use_random: True
  238. bbox_loss:
  239. name: GIoULoss
  240. loss_weight: 120.0
  241. cls_loss_weight: 12.0
  242. # Optimizer
  243. epoch: 12
  244. LearningRate:
  245. base_lr: 0.0002
  246. schedulers:
  247. - !PiecewiseDecay
  248. gamma: 0.1
  249. milestones: [11]
  250. use_warmup: false
  251. OptimizerBuilder:
  252. clip_grad_by_norm: 0.1
  253. regularizer: false
  254. optimizer:
  255. type: AdamW
  256. weight_decay: 0.0001
  257. # Exporting the model
  258. export:
  259. post_process: True # Whether post-processing is included in the network when export model.
  260. nms: True # Whether NMS is included in the network when export model.
  261. benchmark: False # It is used to testing model performance, if set `True`, post-process and NMS will not be exported.
  262. fuse_conv_bn: False