You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

yolox_s_8x8_300e_coco.py 4.2 kB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. _base_ = ['../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py']
  2. # model settings
  3. model = dict(
  4. type='YOLOX',
  5. backbone=dict(type='CSPDarknet', deepen_factor=0.33, widen_factor=0.5),
  6. neck=dict(
  7. type='YOLOXPAFPN',
  8. in_channels=[128, 256, 512],
  9. out_channels=128,
  10. num_csp_blocks=1),
  11. bbox_head=dict(
  12. type='YOLOXHead', num_classes=80, in_channels=128, feat_channels=128),
  13. train_cfg=dict(assigner=dict(type='SimOTAAssigner', center_radius=2.5)),
  14. # In order to align the source code, the threshold of the val phase is
  15. # 0.01, and the threshold of the test phase is 0.001.
  16. test_cfg=dict(score_thr=0.01, nms=dict(type='nms', iou_threshold=0.65)))
  17. # dataset settings
  18. data_root = 'data/coco/'
  19. dataset_type = 'CocoDataset'
  20. img_norm_cfg = dict(
  21. mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
  22. img_scale = (640, 640)
  23. train_pipeline = [
  24. dict(type='Mosaic', img_scale=img_scale, pad_val=114.0),
  25. dict(
  26. type='RandomAffine',
  27. scaling_ratio_range=(0.1, 2),
  28. border=(-img_scale[0] // 2, -img_scale[1] // 2)),
  29. dict(
  30. type='MixUp',
  31. img_scale=img_scale,
  32. ratio_range=(0.8, 1.6),
  33. pad_val=114.0),
  34. dict(
  35. type='PhotoMetricDistortion',
  36. brightness_delta=32,
  37. contrast_range=(0.5, 1.5),
  38. saturation_range=(0.5, 1.5),
  39. hue_delta=18),
  40. dict(type='RandomFlip', flip_ratio=0.5),
  41. dict(type='Resize', keep_ratio=True),
  42. dict(type='Pad', pad_to_square=True, pad_val=114.0),
  43. dict(type='Normalize', **img_norm_cfg),
  44. dict(type='DefaultFormatBundle'),
  45. dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels'])
  46. ]
  47. train_dataset = dict(
  48. type='MultiImageMixDataset',
  49. dataset=dict(
  50. type=dataset_type,
  51. ann_file=data_root + 'annotations/instances_train2017.json',
  52. img_prefix=data_root + 'train2017/',
  53. pipeline=[
  54. dict(type='LoadImageFromFile', to_float32=True),
  55. dict(type='LoadAnnotations', with_bbox=True)
  56. ],
  57. filter_empty_gt=False,
  58. ),
  59. pipeline=train_pipeline,
  60. dynamic_scale=img_scale)
  61. test_pipeline = [
  62. dict(type='LoadImageFromFile'),
  63. dict(
  64. type='MultiScaleFlipAug',
  65. img_scale=img_scale,
  66. flip=False,
  67. transforms=[
  68. dict(type='Resize', keep_ratio=True),
  69. dict(type='RandomFlip'),
  70. dict(type='Pad', size=img_scale, pad_val=114.0),
  71. dict(type='Normalize', **img_norm_cfg),
  72. dict(type='DefaultFormatBundle'),
  73. dict(type='Collect', keys=['img'])
  74. ])
  75. ]
  76. data = dict(
  77. samples_per_gpu=8,
  78. workers_per_gpu=2,
  79. train=train_dataset,
  80. val=dict(
  81. type=dataset_type,
  82. ann_file=data_root + 'annotations/instances_val2017.json',
  83. img_prefix=data_root + 'val2017/',
  84. pipeline=test_pipeline),
  85. test=dict(
  86. type=dataset_type,
  87. ann_file=data_root + 'annotations/instances_val2017.json',
  88. img_prefix=data_root + 'val2017/',
  89. pipeline=test_pipeline))
  90. # optimizer
  91. # default 8 gpu
  92. optimizer = dict(
  93. type='SGD',
  94. lr=0.01,
  95. momentum=0.9,
  96. weight_decay=5e-4,
  97. nesterov=True,
  98. paramwise_cfg=dict(norm_decay_mult=0., bias_decay_mult=0.))
  99. optimizer_config = dict(grad_clip=None)
  100. # learning policy
  101. lr_config = dict(
  102. _delete_=True,
  103. policy='YOLOX',
  104. warmup='exp',
  105. by_epoch=False,
  106. warmup_by_epoch=True,
  107. warmup_ratio=1,
  108. warmup_iters=5, # 5 epoch
  109. num_last_epochs=15,
  110. min_lr_ratio=0.05)
  111. runner = dict(type='EpochBasedRunner', max_epochs=300)
  112. resume_from = None
  113. interval = 10
  114. custom_hooks = [
  115. dict(type='YOLOXModeSwitchHook', num_last_epochs=15, priority=48),
  116. dict(
  117. type='SyncRandomSizeHook',
  118. ratio_range=(14, 26),
  119. img_scale=img_scale,
  120. priority=48),
  121. dict(
  122. type='SyncNormHook',
  123. num_last_epochs=15,
  124. interval=interval,
  125. priority=48),
  126. dict(type='ExpMomentumEMAHook', resume_from=resume_from, priority=49)
  127. ]
  128. checkpoint_config = dict(interval=interval)
  129. evaluation = dict(interval=interval, metric='bbox')
  130. log_config = dict(interval=50)

No Description

Contributors (2)