sparse-rcnn_r50_fpn_1x_coco.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. _base_ = [
  2. '../_base_/datasets/coco_detection.py',
  3. '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
  4. ]
  5. num_stages = 6
  6. num_proposals = 100
  7. model = dict(
  8. type='SparseRCNN',
  9. data_preprocessor=dict(
  10. type='DetDataPreprocessor',
  11. mean=[123.675, 116.28, 103.53],
  12. std=[58.395, 57.12, 57.375],
  13. bgr_to_rgb=True,
  14. pad_size_divisor=32),
  15. backbone=dict(
  16. type='ResNet',
  17. depth=50,
  18. num_stages=4,
  19. out_indices=(0, 1, 2, 3),
  20. frozen_stages=1,
  21. norm_cfg=dict(type='BN', requires_grad=True),
  22. norm_eval=True,
  23. style='pytorch',
  24. init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet50')),
  25. neck=dict(
  26. type='FPN',
  27. in_channels=[256, 512, 1024, 2048],
  28. out_channels=256,
  29. start_level=0,
  30. add_extra_convs='on_input',
  31. num_outs=4),
  32. rpn_head=dict(
  33. type='EmbeddingRPNHead',
  34. num_proposals=num_proposals,
  35. proposal_feature_channel=256),
  36. roi_head=dict(
  37. type='SparseRoIHead',
  38. num_stages=num_stages,
  39. stage_loss_weights=[1] * num_stages,
  40. proposal_feature_channel=256,
  41. bbox_roi_extractor=dict(
  42. type='SingleRoIExtractor',
  43. roi_layer=dict(type='RoIAlign', output_size=7, sampling_ratio=2),
  44. out_channels=256,
  45. featmap_strides=[4, 8, 16, 32]),
  46. bbox_head=[
  47. dict(
  48. type='DIIHead',
  49. num_classes=80,
  50. num_ffn_fcs=2,
  51. num_heads=8,
  52. num_cls_fcs=1,
  53. num_reg_fcs=3,
  54. feedforward_channels=2048,
  55. in_channels=256,
  56. dropout=0.0,
  57. ffn_act_cfg=dict(type='ReLU', inplace=True),
  58. dynamic_conv_cfg=dict(
  59. type='DynamicConv',
  60. in_channels=256,
  61. feat_channels=64,
  62. out_channels=256,
  63. input_feat_shape=7,
  64. act_cfg=dict(type='ReLU', inplace=True),
  65. norm_cfg=dict(type='LN')),
  66. loss_bbox=dict(type='L1Loss', loss_weight=5.0),
  67. loss_iou=dict(type='GIoULoss', loss_weight=2.0),
  68. loss_cls=dict(
  69. type='FocalLoss',
  70. use_sigmoid=True,
  71. gamma=2.0,
  72. alpha=0.25,
  73. loss_weight=2.0),
  74. bbox_coder=dict(
  75. type='DeltaXYWHBBoxCoder',
  76. clip_border=False,
  77. target_means=[0., 0., 0., 0.],
  78. target_stds=[0.5, 0.5, 1., 1.])) for _ in range(num_stages)
  79. ]),
  80. # training and testing settings
  81. train_cfg=dict(
  82. rpn=None,
  83. rcnn=[
  84. dict(
  85. assigner=dict(
  86. type='HungarianAssigner',
  87. match_costs=[
  88. dict(type='FocalLossCost', weight=2.0),
  89. dict(type='BBoxL1Cost', weight=5.0, box_format='xyxy'),
  90. dict(type='IoUCost', iou_mode='giou', weight=2.0)
  91. ]),
  92. sampler=dict(type='PseudoSampler'),
  93. pos_weight=1) for _ in range(num_stages)
  94. ]),
  95. test_cfg=dict(rpn=None, rcnn=dict(max_per_img=num_proposals)))
  96. # optimizer
  97. optim_wrapper = dict(
  98. optimizer=dict(
  99. _delete_=True, type='AdamW', lr=0.000025, weight_decay=0.0001),
  100. clip_grad=dict(max_norm=1, norm_type=2))