Skip to content

Commit 84fbb2c

Browse files
authored
Simplify _base_ config (open-mmlab#3166)
1 parent ef03d17 commit 84fbb2c

File tree

5 files changed

+110
-11
lines changed

5 files changed

+110
-11
lines changed

configs/_base_/datasets/cityscapes_instance.py

+41-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
_base_ = './cityscapes_detection.py'
1+
dataset_type = 'CityscapesDataset'
2+
data_root = 'data/cityscapes/'
23
img_norm_cfg = dict(
34
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
45
train_pipeline = [
@@ -12,5 +13,43 @@
1213
dict(type='DefaultFormatBundle'),
1314
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']),
1415
]
15-
data = dict(train=dict(dataset=dict(pipeline=train_pipeline)))
16+
test_pipeline = [
17+
dict(type='LoadImageFromFile'),
18+
dict(
19+
type='MultiScaleFlipAug',
20+
img_scale=(2048, 1024),
21+
flip=False,
22+
transforms=[
23+
dict(type='Resize', keep_ratio=True),
24+
dict(type='RandomFlip'),
25+
dict(type='Normalize', **img_norm_cfg),
26+
dict(type='Pad', size_divisor=32),
27+
dict(type='ImageToTensor', keys=['img']),
28+
dict(type='Collect', keys=['img']),
29+
])
30+
]
31+
data = dict(
32+
samples_per_gpu=1,
33+
workers_per_gpu=2,
34+
train=dict(
35+
type='RepeatDataset',
36+
times=8,
37+
dataset=dict(
38+
type=dataset_type,
39+
ann_file=data_root +
40+
'annotations/instancesonly_filtered_gtFine_train.json',
41+
img_prefix=data_root + 'leftImg8bit/train/',
42+
pipeline=train_pipeline)),
43+
val=dict(
44+
type=dataset_type,
45+
ann_file=data_root +
46+
'annotations/instancesonly_filtered_gtFine_val.json',
47+
img_prefix=data_root + 'leftImg8bit/val/',
48+
pipeline=test_pipeline),
49+
test=dict(
50+
type=dataset_type,
51+
ann_file=data_root +
52+
'annotations/instancesonly_filtered_gtFine_test.json',
53+
img_prefix=data_root + 'leftImg8bit/test/',
54+
pipeline=test_pipeline))
1655
evaluation = dict(metric=['bbox', 'segm'])

configs/_base_/datasets/coco_instance.py

+35-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
_base_ = 'coco_detection.py'
1+
dataset_type = 'CocoDataset'
2+
data_root = 'data/coco/'
23
img_norm_cfg = dict(
34
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
45
train_pipeline = [
@@ -11,5 +12,37 @@
1112
dict(type='DefaultFormatBundle'),
1213
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']),
1314
]
14-
data = dict(train=dict(pipeline=train_pipeline))
15+
test_pipeline = [
16+
dict(type='LoadImageFromFile'),
17+
dict(
18+
type='MultiScaleFlipAug',
19+
img_scale=(1333, 800),
20+
flip=False,
21+
transforms=[
22+
dict(type='Resize', keep_ratio=True),
23+
dict(type='RandomFlip'),
24+
dict(type='Normalize', **img_norm_cfg),
25+
dict(type='Pad', size_divisor=32),
26+
dict(type='ImageToTensor', keys=['img']),
27+
dict(type='Collect', keys=['img']),
28+
])
29+
]
30+
data = dict(
31+
samples_per_gpu=2,
32+
workers_per_gpu=2,
33+
train=dict(
34+
type=dataset_type,
35+
ann_file=data_root + 'annotations/instances_train2017.json',
36+
img_prefix=data_root + 'train2017/',
37+
pipeline=train_pipeline),
38+
val=dict(
39+
type=dataset_type,
40+
ann_file=data_root + 'annotations/instances_val2017.json',
41+
img_prefix=data_root + 'val2017/',
42+
pipeline=test_pipeline),
43+
test=dict(
44+
type=dataset_type,
45+
ann_file=data_root + 'annotations/instances_val2017.json',
46+
img_prefix=data_root + 'val2017/',
47+
pipeline=test_pipeline))
1548
evaluation = dict(metric=['bbox', 'segm'])

configs/_base_/datasets/coco_instance_semantic.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
_base_ = 'coco_detection.py'
1+
dataset_type = 'CocoDataset'
22
data_root = 'data/coco/'
33
img_norm_cfg = dict(
44
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
@@ -32,9 +32,22 @@
3232
])
3333
]
3434
data = dict(
35+
samples_per_gpu=2,
36+
workers_per_gpu=2,
3537
train=dict(
38+
type=dataset_type,
39+
ann_file=data_root + 'annotations/instances_train2017.json',
40+
img_prefix=data_root + 'train2017/',
3641
seg_prefix=data_root + 'stuffthingmaps/train2017/',
3742
pipeline=train_pipeline),
38-
val=dict(pipeline=test_pipeline),
39-
test=dict(pipeline=test_pipeline))
43+
val=dict(
44+
type=dataset_type,
45+
ann_file=data_root + 'annotations/instances_val2017.json',
46+
img_prefix=data_root + 'val2017/',
47+
pipeline=test_pipeline),
48+
test=dict(
49+
type=dataset_type,
50+
ann_file=data_root + 'annotations/instances_val2017.json',
51+
img_prefix=data_root + 'val2017/',
52+
pipeline=test_pipeline))
4053
evaluation = dict(metric=['bbox', 'segm'])
+9-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
_base_ = './schedule_1x.py'
1+
# optimizer
2+
optimizer = dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001)
3+
optimizer_config = dict(grad_clip=None)
24
# learning policy
3-
lr_config = dict(step=[16, 19])
5+
lr_config = dict(
6+
policy='step',
7+
warmup='linear',
8+
warmup_iters=500,
9+
warmup_ratio=0.001,
10+
step=[16, 19])
411
total_epochs = 20
+9-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
_base_ = './schedule_1x.py'
1+
# optimizer
2+
optimizer = dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001)
3+
optimizer_config = dict(grad_clip=None)
24
# learning policy
3-
lr_config = dict(step=[16, 22])
5+
lr_config = dict(
6+
policy='step',
7+
warmup='linear',
8+
warmup_iters=500,
9+
warmup_ratio=0.001,
10+
step=[16, 22])
411
total_epochs = 24

0 commit comments

Comments
 (0)