fcos_config.py 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. # Fully Convolutional One-Stage object detector
  2. class FcosBaseConfig(object):
  3. def __init__(self):
  4. pass
  5. def print_config(self):
  6. config_dict = {key: value for key, value in self.__dict__.items() if not key.startswith('__')}
  7. for k, v in config_dict.items():
  8. print("{} : {}".format(k, v))
  9. fcos_cfg = {
  10. 'fcos_r18_1x':{
  11. # ----------------- Model-----------------
  12. ## Backbone
  13. 'backbone': 'resnet18',
  14. 'backbone_norm': 'FrozeBN',
  15. 'res5_dilation': False,
  16. 'pretrained': True,
  17. 'freeze_at': 1, # freeze stem layer + layer1 of the backbone
  18. 'pretrained_weight': 'imagenet1k_v1',
  19. 'max_stride': 128,
  20. 'out_stride': [8, 16, 32, 64, 128],
  21. ## Neck
  22. 'neck': 'basic_fpn',
  23. 'fpn_p6_feat': True,
  24. 'fpn_p7_feat': True,
  25. 'fpn_p6_from_c5': False,
  26. ## Head
  27. 'head': 'fcos_head',
  28. 'head_dim': 256,
  29. 'num_cls_head': 4,
  30. 'num_reg_head': 4,
  31. 'head_act': 'relu',
  32. 'head_norm': 'GN',
  33. ## Post-process
  34. 'train_topk': 1000,
  35. 'train_conf_thresh': 0.05,
  36. 'train_nms_thresh': 0.6,
  37. 'test_topk': 100,
  38. 'test_conf_thresh': 0.5,
  39. 'test_nms_thresh': 0.45,
  40. 'nms_class_agnostic': True, # We prefer to use class-agnostic NMS in the demo.
  41. # ----------------- Label Assignment -----------------
  42. 'matcher': 'fcos_matcher',
  43. 'matcher_hpy':{'center_sampling_radius': 1.5,
  44. 'object_sizes_of_interest': [[-1, 64], [64, 128], [128, 256], [256, 512], [512, float('inf')]]
  45. },
  46. # ----------------- Loss weight -----------------
  47. ## Loss hyper-parameters
  48. 'focal_loss_alpha': 0.25,
  49. 'focal_loss_gamma': 2.0,
  50. 'loss_cls_weight': 1.0,
  51. 'loss_reg_weight': 1.0,
  52. 'loss_ctn_weight': 1.0,
  53. # ----------------- Training -----------------
  54. ## Training scheduler
  55. 'scheduler': '1x',
  56. ## Optimizer
  57. 'optimizer': 'sgd',
  58. 'base_lr': 0.01 / 16,
  59. 'backbone_lr_ratio': 1.0 / 1.0,
  60. 'momentum': 0.9,
  61. 'weight_decay': 1e-4,
  62. 'clip_max_norm': -1.0,
  63. 'param_dict_type': 'default',
  64. ## LR Scheduler
  65. 'lr_scheduler': 'step',
  66. 'warmup': 'linear',
  67. 'warmup_iters': 500,
  68. 'warmup_factor': 0.00066667,
  69. ## Epoch
  70. 'max_epoch': 12, # 1x
  71. 'lr_epoch': [8, 11], # 1x
  72. # ----------------- Input -----------------
  73. ## Transforms
  74. 'train_min_size': [800], # short edge of image
  75. 'train_max_size': 1333,
  76. 'test_min_size': [800],
  77. 'test_max_size': 1333,
  78. ## Pixel mean & std
  79. 'pixel_mean': [0.485, 0.456, 0.406],
  80. 'pixel_std': [0.229, 0.224, 0.225],
  81. ## Transforms
  82. 'detr_style': False,
  83. 'trans_config': [
  84. {'name': 'RandomHFlip'},
  85. {'name': 'RandomResize'},
  86. ],
  87. 'box_format': 'xyxy',
  88. 'normalize_coords': False,
  89. },
  90. 'fcos_r50_1x':{
  91. # ----------------- Model-----------------
  92. ## Backbone
  93. 'backbone': 'resnet50',
  94. 'backbone_norm': 'FrozeBN',
  95. 'res5_dilation': False,
  96. 'pretrained': True,
  97. 'freeze_at': 1, # freeze stem layer + layer1 of the backbone
  98. 'pretrained_weight': 'imagenet1k_v1',
  99. 'max_stride': 128,
  100. 'out_stride': [8, 16, 32, 64, 128],
  101. ## Neck
  102. 'neck': 'basic_fpn',
  103. 'fpn_p6_feat': True,
  104. 'fpn_p7_feat': True,
  105. 'fpn_p6_from_c5': False,
  106. ## Head
  107. 'head': 'fcos_head',
  108. 'head_dim': 256,
  109. 'num_cls_head': 4,
  110. 'num_reg_head': 4,
  111. 'head_act': 'relu',
  112. 'head_norm': 'GN',
  113. ## Post-process
  114. 'train_topk': 1000,
  115. 'train_conf_thresh': 0.05,
  116. 'train_nms_thresh': 0.65,
  117. 'test_topk': 100,
  118. 'test_conf_thresh': 0.5,
  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': 'fcos_matcher',
  123. 'matcher_hpy':{'center_sampling_radius': 1.5,
  124. 'object_sizes_of_interest': [[-1, 64], [64, 128], [128, 256], [256, 512], [512, float('inf')]]
  125. },
  126. # ----------------- Loss weight -----------------
  127. ## Loss hyper-parameters
  128. 'focal_loss_alpha': 0.25,
  129. 'focal_loss_gamma': 2.0,
  130. 'loss_cls_weight': 1.0,
  131. 'loss_reg_weight': 1.0,
  132. 'loss_ctn_weight': 1.0,
  133. # ----------------- Training -----------------
  134. ## Training scheduler
  135. 'scheduler': '1x',
  136. ## Optimizer
  137. 'optimizer': 'sgd',
  138. 'base_lr': 0.01 / 16,
  139. 'backbone_lr_ratio': 1.0 / 1.0,
  140. 'momentum': 0.9,
  141. 'weight_decay': 1e-4,
  142. 'clip_max_norm': -1.0,
  143. 'param_dict_type': 'default',
  144. ## LR Scheduler
  145. 'lr_scheduler': 'step',
  146. 'warmup': 'linear',
  147. 'warmup_iters': 500,
  148. 'warmup_factor': 0.00066667,
  149. ## Epoch
  150. 'max_epoch': 12, # 1x
  151. 'lr_epoch': [8, 11], # 1x
  152. # ----------------- Input -----------------
  153. ## Transforms
  154. 'train_min_size': [800], # short edge of image
  155. 'train_max_size': 1333,
  156. 'test_min_size': [800],
  157. 'test_max_size': 1333,
  158. ## Pixel mean & std
  159. 'pixel_mean': [0.485, 0.456, 0.406],
  160. 'pixel_std': [0.229, 0.224, 0.225],
  161. ## Transforms
  162. 'detr_style': False,
  163. 'trans_config': [
  164. {'name': 'RandomHFlip'},
  165. {'name': 'RandomResize'},
  166. ],
  167. 'box_format': 'xyxy',
  168. 'normalize_coords': False,
  169. },
  170. 'fcos_rt_r18_1x':{
  171. # ----------------- Model-----------------
  172. ## Backbone
  173. 'backbone': 'resnet18',
  174. 'backbone_norm': 'FrozeBN',
  175. 'res5_dilation': False,
  176. 'pretrained': True,
  177. 'freeze_at': 1, # freeze stem layer + layer1 of the backbone
  178. 'pretrained_weight': 'imagenet1k_v1',
  179. 'max_stride': 32,
  180. 'out_stride': [8, 16, 32],
  181. ## Neck
  182. 'neck': 'basic_fpn',
  183. 'fpn_p6_feat': False,
  184. 'fpn_p7_feat': False,
  185. 'fpn_p6_from_c5': False,
  186. ## Head
  187. 'head': 'fcos_head',
  188. 'head_dim': 256,
  189. 'num_cls_head': 4,
  190. 'num_reg_head': 4,
  191. 'head_act': 'relu',
  192. 'head_norm': 'GN',
  193. ## Post-process
  194. 'train_topk': 1000,
  195. 'train_conf_thresh': 0.05,
  196. 'train_nms_thresh': 0.6,
  197. 'test_topk': 100,
  198. 'test_conf_thresh': 0.5,
  199. 'test_nms_thresh': 0.45,
  200. 'nms_class_agnostic': True, # We prefer to use class-agnostic NMS in the demo.
  201. # ----------------- Label Assignment -----------------
  202. 'matcher': 'fcos_matcher',
  203. 'matcher_hpy':{'center_sampling_radius': 1.5,
  204. 'object_sizes_of_interest': [[-1, 64], [64, 128], [128, float('inf')]]
  205. },
  206. # ----------------- Loss weight -----------------
  207. ## Loss hyper-parameters
  208. 'focal_loss_alpha': 0.25,
  209. 'focal_loss_gamma': 2.0,
  210. 'loss_cls_weight': 1.0,
  211. 'loss_reg_weight': 1.0,
  212. 'loss_ctn_weight': 1.0,
  213. # ----------------- Training -----------------
  214. ## Training scheduler
  215. 'scheduler': '1x',
  216. ## Optimizer
  217. 'optimizer': 'sgd',
  218. 'base_lr': 0.01 / 16,
  219. 'backbone_lr_ratio': 1.0 / 1.0,
  220. 'momentum': 0.9,
  221. 'weight_decay': 1e-4,
  222. 'clip_max_norm': -1.0,
  223. ## LR Scheduler
  224. 'lr_scheduler': 'step',
  225. 'warmup': 'linear',
  226. 'warmup_iters': 500,
  227. 'warmup_factor': 0.00066667,
  228. ## Epoch
  229. 'max_epoch': 36, # 1x
  230. 'lr_epoch': [24, 33], # 1x
  231. # ----------------- Input -----------------
  232. ## Transforms
  233. 'train_min_size': [256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608], # short edge of image
  234. 'train_max_size': 900,
  235. 'test_min_size': [512],
  236. 'test_max_size': 736,
  237. ## Pixel mean & std
  238. 'pixel_mean': [0.485, 0.456, 0.406],
  239. 'pixel_std': [0.229, 0.224, 0.225],
  240. ## Transforms
  241. 'detr_style': False,
  242. 'trans_config': [
  243. {'name': 'RandomHFlip'},
  244. {'name': 'RandomResize'},
  245. ],
  246. 'box_format': 'xyxy',
  247. 'normalize_coords': False,
  248. },
  249. 'fcos_rt_r50_1x':{
  250. # ----------------- Model-----------------
  251. ## Backbone
  252. 'backbone': 'resnet50',
  253. 'backbone_norm': 'FrozeBN',
  254. 'res5_dilation': False,
  255. 'pretrained': True,
  256. 'freeze_at': 1, # freeze stem layer + layer1 of the backbone
  257. 'pretrained_weight': 'imagenet1k_v1',
  258. 'max_stride': 32,
  259. 'out_stride': [8, 16, 32],
  260. ## Neck
  261. 'neck': 'basic_fpn',
  262. 'fpn_p6_feat': False,
  263. 'fpn_p7_feat': False,
  264. 'fpn_p6_from_c5': False,
  265. ## Head
  266. 'head': 'fcos_head',
  267. 'head_dim': 256,
  268. 'num_cls_head': 4,
  269. 'num_reg_head': 4,
  270. 'head_act': 'relu',
  271. 'head_norm': 'GN',
  272. ## Post-process
  273. 'train_topk': 1000,
  274. 'train_conf_thresh': 0.05,
  275. 'train_nms_thresh': 0.6,
  276. 'test_topk': 100,
  277. 'test_conf_thresh': 0.5,
  278. 'test_nms_thresh': 0.45,
  279. 'nms_class_agnostic': True, # We prefer to use class-agnostic NMS in the demo.
  280. # ----------------- Label Assignment -----------------
  281. 'matcher': 'fcos_matcher',
  282. 'matcher_hpy':{'center_sampling_radius': 1.5,
  283. 'object_sizes_of_interest': [[-1, 64], [64, 128], [128, float('inf')]]
  284. },
  285. # ----------------- Loss weight -----------------
  286. ## Loss hyper-parameters
  287. 'focal_loss_alpha': 0.25,
  288. 'focal_loss_gamma': 2.0,
  289. 'loss_cls_weight': 1.0,
  290. 'loss_reg_weight': 1.0,
  291. 'loss_ctn_weight': 1.0,
  292. # ----------------- Training -----------------
  293. ## Training scheduler
  294. 'scheduler': '1x',
  295. ## Optimizer
  296. 'optimizer': 'sgd',
  297. 'base_lr': 0.01 / 16,
  298. 'backbone_lr_ratio': 1.0 / 1.0,
  299. 'momentum': 0.9,
  300. 'weight_decay': 1e-4,
  301. 'clip_max_norm': -1.0,
  302. ## LR Scheduler
  303. 'lr_scheduler': 'step',
  304. 'warmup': 'linear',
  305. 'warmup_iters': 500,
  306. 'warmup_factor': 0.00066667,
  307. ## Epoch
  308. 'max_epoch': 36, # 1x
  309. 'lr_epoch': [24, 33], # 1x
  310. # ----------------- Input -----------------
  311. ## Transforms
  312. 'train_min_size': [256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608], # short edge of image
  313. 'train_max_size': 900,
  314. 'test_min_size': [512],
  315. 'test_max_size': 736,
  316. ## Pixel mean & std
  317. 'pixel_mean': [0.485, 0.456, 0.406],
  318. 'pixel_std': [0.229, 0.224, 0.225],
  319. ## Transforms
  320. 'detr_style': False,
  321. 'trans_config': [
  322. {'name': 'RandomHFlip'},
  323. {'name': 'RandomResize'},
  324. ],
  325. 'box_format': 'xyxy',
  326. 'normalize_coords': False,
  327. },
  328. }