retinanet_config.py 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. # RetinaNet
  2. retinanet_cfg = {
  3. 'retinanet_r18_1x':{
  4. # ----------------- Model-----------------
  5. ## Backbone
  6. 'backbone': 'resnet18',
  7. 'backbone_norm': 'FrozeBN',
  8. 'res5_dilation': False,
  9. 'pretrained': True,
  10. 'pretrained_weight': 'imagenet1k_v1',
  11. 'freeze_at': 1, # freeze stem layer + layer1 of the backbone
  12. 'max_stride': 128,
  13. 'out_stride': [8, 16, 32, 64, 128],
  14. ## Neck
  15. 'neck': 'basic_fpn',
  16. 'fpn_p6_feat': True,
  17. 'fpn_p7_feat': True,
  18. 'fpn_p6_from_c5': True,
  19. ## Head
  20. 'head': 'retinanet_head',
  21. 'head_dim': 256,
  22. 'num_cls_head': 4,
  23. 'num_reg_head': 4,
  24. 'head_act': 'relu',
  25. 'head_norm': None,
  26. 'anchor_config': {'basic_size': [[32, 32], [64, 64], [128, 128], [256, 256], [512, 512]],
  27. 'aspect_ratio': [0.5, 1.0, 2.0],
  28. 'area_scale': [2 ** 0, 2 ** (1. / 3.), 2 ** (2. / 3.)]},
  29. ## Post-process
  30. 'train_topk': 1000,
  31. 'train_conf_thresh': 0.05,
  32. 'train_nms_thresh': 0.6,
  33. 'test_topk': 100,
  34. 'test_conf_thresh': 0.3,
  35. 'test_nms_thresh': 0.45,
  36. 'nms_class_agnostic': True, # We prefer to use class-agnostic NMS in the demo.
  37. # ----------------- Label Assignment -----------------
  38. 'matcher': 'retinanet_matcher',
  39. 'matcher_hpy': {'iou_thresh': [0.4, 0.5],
  40. 'iou_labels': [0, -1, 1], # [negative sample, ignored sample, positive sample]
  41. 'allow_low_quality_matches': True,
  42. },
  43. # ----------------- Loss weight -----------------
  44. ## Loss hyper-parameters
  45. 'focal_loss_alpha': 0.25,
  46. 'focal_loss_gamma': 2.0,
  47. 'loss_cls_weight': 1.0,
  48. 'loss_reg_weight': 1.0,
  49. 'use_giou_loss': False,
  50. # ----------------- Training -----------------
  51. ## Training scheduler
  52. 'scheduler': '1x',
  53. ## Optimizer
  54. 'optimizer': 'sgd',
  55. 'base_lr': 0.01 / 16,
  56. 'backbone_lr_ratio': 1.0 / 1.0,
  57. 'momentum': 0.9,
  58. 'weight_decay': 1e-4,
  59. 'clip_max_norm': -1.0,
  60. 'param_dict_type': 'default',
  61. ## LR Scheduler
  62. 'lr_scheduler': 'step',
  63. 'warmup': 'linear',
  64. 'warmup_iters': 500,
  65. 'warmup_factor': 0.00066667,
  66. ## Epoch
  67. 'max_epoch': 12, # 1x
  68. 'lr_epoch': [8, 11], # 1x
  69. # ----------------- Input -----------------
  70. ## Transforms
  71. 'train_min_size': [800], # short edge of image
  72. 'train_max_size': 1333,
  73. 'test_min_size': [800],
  74. 'test_max_size': 1333,
  75. ## Pixel mean & std
  76. 'pixel_mean': [0.485, 0.456, 0.406],
  77. 'pixel_std': [0.229, 0.224, 0.225],
  78. ## Transforms
  79. 'detr_style': False,
  80. 'trans_config': [
  81. {'name': 'RandomHFlip'},
  82. {'name': 'RandomResize'},
  83. ],
  84. 'box_format': 'xyxy',
  85. 'normalize_coords': False,
  86. },
  87. 'retinanet_r50_1x':{
  88. # ----------------- Model-----------------
  89. ## Backbone
  90. 'backbone': 'resnet50',
  91. 'backbone_norm': 'FrozeBN',
  92. 'res5_dilation': False,
  93. 'pretrained': True,
  94. 'pretrained_weight': 'imagenet1k_v1',
  95. 'freeze_at': 1, # freeze stem layer + layer1 of the backbone
  96. 'max_stride': 128,
  97. 'out_stride': [8, 16, 32, 64, 128],
  98. ## Neck
  99. 'neck': 'basic_fpn',
  100. 'fpn_p6_feat': True,
  101. 'fpn_p7_feat': True,
  102. 'fpn_p6_from_c5': True,
  103. ## Head
  104. 'head': 'retinanet_head',
  105. 'head_dim': 256,
  106. 'num_cls_head': 4,
  107. 'num_reg_head': 4,
  108. 'head_act': 'relu',
  109. 'head_norm': None,
  110. 'anchor_config': {'basic_size': [[32, 32], [64, 64], [128, 128], [256, 256], [512, 512]],
  111. 'aspect_ratio': [0.5, 1.0, 2.0],
  112. 'area_scale': [2 ** 0, 2 ** (1. / 3.), 2 ** (2. / 3.)]},
  113. ## Post-process
  114. 'train_topk': 1000,
  115. 'train_conf_thresh': 0.05,
  116. 'train_nms_thresh': 0.6,
  117. 'test_topk': 100,
  118. 'test_conf_thresh': 0.3,
  119. 'test_nms_thresh': 0.45,
  120. 'nms_class_agnostic': True, # We prefer to use class-agnostic NMS in the demo.
  121. # ----------------- Label Assignment -----------------
  122. 'matcher': 'retinanet_matcher',
  123. 'matcher_hpy': {'iou_thresh': [0.4, 0.5],
  124. 'iou_labels': [0, -1, 1], # [negative sample, ignored sample, positive sample]
  125. 'allow_low_quality_matches': True,
  126. },
  127. # ----------------- Loss weight -----------------
  128. ## Loss hyper-parameters
  129. 'focal_loss_alpha': 0.25,
  130. 'focal_loss_gamma': 2.0,
  131. 'loss_cls_weight': 1.0,
  132. 'loss_reg_weight': 1.0,
  133. 'use_giou_loss': False,
  134. # ----------------- Training -----------------
  135. ## Training scheduler
  136. 'scheduler': '1x',
  137. ## Optimizer
  138. 'optimizer': 'sgd',
  139. 'base_lr': 0.01 / 16,
  140. 'backbone_lr_ratio': 1.0 / 1.0,
  141. 'momentum': 0.9,
  142. 'weight_decay': 1e-4,
  143. 'clip_max_norm': -1.0,
  144. 'param_dict_type': 'default',
  145. ## LR Scheduler
  146. 'lr_scheduler': 'step',
  147. 'warmup': 'linear',
  148. 'warmup_iters': 500,
  149. 'warmup_factor': 0.00066667,
  150. ## Epoch
  151. 'max_epoch': 12, # 1x
  152. 'lr_epoch': [8, 11], # 1x
  153. # ----------------- Input -----------------
  154. ## Transforms
  155. 'train_min_size': [800], # short edge of image
  156. 'train_max_size': 1333,
  157. 'test_min_size': [800],
  158. 'test_max_size': 1333,
  159. ## Pixel mean & std
  160. 'pixel_mean': [0.485, 0.456, 0.406],
  161. 'pixel_std': [0.229, 0.224, 0.225],
  162. ## Transforms
  163. 'detr_style': False,
  164. 'trans_config': [
  165. {'name': 'RandomHFlip'},
  166. {'name': 'RandomResize'},
  167. ],
  168. 'box_format': 'xyxy',
  169. 'normalize_coords': False,
  170. },
  171. }