|
1 | 1 | _base_ = ['../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py']
|
2 | 2 |
|
| 3 | +img_scale = (640, 640) |
| 4 | + |
3 | 5 | # model settings
|
4 | 6 | model = dict(
|
5 | 7 | type='YOLOX',
|
| 8 | + input_size=img_scale, |
| 9 | + random_size_range=(15, 25), |
| 10 | + random_size_interval=10, |
6 | 11 | backbone=dict(type='CSPDarknet', deepen_factor=0.33, widen_factor=0.5),
|
7 | 12 | neck=dict(
|
8 | 13 | type='YOLOXPAFPN',
|
|
20 | 25 | data_root = 'data/coco/'
|
21 | 26 | dataset_type = 'CocoDataset'
|
22 | 27 |
|
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 | 28 | train_pipeline = [
|
29 | 29 | dict(type='Mosaic', img_scale=img_scale, pad_val=114.0),
|
30 | 30 | dict(
|
|
36 | 36 | img_scale=img_scale,
|
37 | 37 | ratio_range=(0.8, 1.6),
|
38 | 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), |
| 39 | + dict(type='YOLOXHSVRandomAug'), |
45 | 40 | 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), |
| 41 | + # According to the official implementation, multi-scale |
| 42 | + # training is not considered here but in the |
| 43 | + # 'mmdet/models/detectors/yolox.py'. |
| 44 | + dict(type='Resize', img_scale=img_scale, keep_ratio=True), |
| 45 | + dict( |
| 46 | + type='Pad', |
| 47 | + pad_to_square=True, |
| 48 | + # If the image is three-channel, the pad value needs |
| 49 | + # to be set separately for each channel. |
| 50 | + pad_val=dict(img=(114.0, 114.0, 114.0))), |
| 51 | + dict(type='FilterAnnotations', min_gt_bbox_wh=(1, 1), keep_empty=False), |
49 | 52 | dict(type='DefaultFormatBundle'),
|
50 | 53 | dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels'])
|
51 | 54 | ]
|
|
57 | 60 | ann_file=data_root + 'annotations/instances_train2017.json',
|
58 | 61 | img_prefix=data_root + 'train2017/',
|
59 | 62 | pipeline=[
|
60 |
| - dict(type='LoadImageFromFile', to_float32=True), |
| 63 | + dict(type='LoadImageFromFile'), |
61 | 64 | dict(type='LoadAnnotations', with_bbox=True)
|
62 | 65 | ],
|
63 | 66 | filter_empty_gt=False,
|
64 | 67 | ),
|
65 |
| - pipeline=train_pipeline, |
66 |
| - dynamic_scale=img_scale) |
| 68 | + pipeline=train_pipeline) |
67 | 69 |
|
68 | 70 | test_pipeline = [
|
69 | 71 | dict(type='LoadImageFromFile'),
|
|
74 | 76 | transforms=[
|
75 | 77 | dict(type='Resize', keep_ratio=True),
|
76 | 78 | dict(type='RandomFlip'),
|
77 |
| - dict(type='Pad', size=img_scale, pad_val=114.0), |
78 |
| - dict(type='Normalize', **img_norm_cfg), |
| 79 | + dict( |
| 80 | + type='Pad', |
| 81 | + pad_to_square=True, |
| 82 | + pad_val=dict(img=(114.0, 114.0, 114.0))), |
79 | 83 | dict(type='DefaultFormatBundle'),
|
80 | 84 | dict(type='Collect', keys=['img'])
|
81 | 85 | ])
|
82 | 86 | ]
|
83 | 87 |
|
84 | 88 | data = dict(
|
85 | 89 | samples_per_gpu=8,
|
86 |
| - workers_per_gpu=2, |
| 90 | + workers_per_gpu=4, |
| 91 | + persistent_workers=True, |
87 | 92 | train=train_dataset,
|
88 | 93 | val=dict(
|
89 | 94 | type=dataset_type,
|
|
107 | 112 | paramwise_cfg=dict(norm_decay_mult=0., bias_decay_mult=0.))
|
108 | 113 | optimizer_config = dict(grad_clip=None)
|
109 | 114 |
|
| 115 | +max_epochs = 300 |
| 116 | +num_last_epochs = 15 |
| 117 | +resume_from = None |
| 118 | +interval = 10 |
| 119 | + |
110 | 120 | # learning policy
|
111 | 121 | lr_config = dict(
|
112 | 122 | _delete_=True,
|
|
116 | 126 | warmup_by_epoch=True,
|
117 | 127 | warmup_ratio=1,
|
118 | 128 | warmup_iters=5, # 5 epoch
|
119 |
| - num_last_epochs=15, |
| 129 | + num_last_epochs=num_last_epochs, |
120 | 130 | min_lr_ratio=0.05)
|
121 |
| -runner = dict(type='EpochBasedRunner', max_epochs=300) |
122 | 131 |
|
123 |
| -resume_from = None |
124 |
| -interval = 10 |
| 132 | +runner = dict(type='EpochBasedRunner', max_epochs=max_epochs) |
125 | 133 |
|
126 | 134 | custom_hooks = [
|
127 |
| - dict(type='YOLOXModeSwitchHook', num_last_epochs=15, priority=48), |
128 | 135 | dict(
|
129 |
| - type='SyncRandomSizeHook', |
130 |
| - ratio_range=(14, 26), |
131 |
| - img_scale=img_scale, |
| 136 | + type='YOLOXModeSwitchHook', |
| 137 | + num_last_epochs=num_last_epochs, |
132 | 138 | priority=48),
|
133 | 139 | dict(
|
134 | 140 | type='SyncNormHook',
|
135 |
| - num_last_epochs=15, |
| 141 | + num_last_epochs=num_last_epochs, |
136 | 142 | interval=interval,
|
137 | 143 | priority=48),
|
138 |
| - dict(type='ExpMomentumEMAHook', resume_from=resume_from, priority=49) |
| 144 | + dict( |
| 145 | + type='ExpMomentumEMAHook', |
| 146 | + resume_from=resume_from, |
| 147 | + momentum=0.0001, |
| 148 | + priority=49) |
139 | 149 | ]
|
140 | 150 | checkpoint_config = dict(interval=interval)
|
141 |
| -evaluation = dict(interval=interval, metric='bbox') |
| 151 | +evaluation = dict( |
| 152 | + save_best='auto', |
| 153 | + # The evaluation interval is 'interval' when running epoch is |
| 154 | + # less than ‘max_epochs - num_last_epochs’. |
| 155 | + # The evaluation interval is 1 when running epoch is greater than |
| 156 | + # or equal to ‘max_epochs - num_last_epochs’. |
| 157 | + interval=interval, |
| 158 | + dynamic_intervals=[(max_epochs - num_last_epochs, 1)], |
| 159 | + metric='bbox') |
142 | 160 | log_config = dict(interval=50)
|
0 commit comments