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