-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Pascal Context 59 classes (#459)
* Create PascalContextDataset59 class in mmseg/datasets/pascal_context.py; * Set reduce_zero_label=True for train_pipeline and PascalContextDataset59; * Add some configs for Pascal-Context 59 classes training and testing;
- Loading branch information
sennnnn
committed
Apr 8, 2021
1 parent
9524f37
commit b081822
Showing
15 changed files
with
232 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# dataset settings | ||
dataset_type = 'PascalContextDataset59' | ||
data_root = 'data/VOCdevkit/VOC2010/' | ||
img_norm_cfg = dict( | ||
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) | ||
|
||
img_scale = (520, 520) | ||
crop_size = (480, 480) | ||
|
||
train_pipeline = [ | ||
dict(type='LoadImageFromFile'), | ||
dict(type='LoadAnnotations', reduce_zero_label=True), | ||
dict(type='Resize', img_scale=img_scale, ratio_range=(0.5, 2.0)), | ||
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75), | ||
dict(type='RandomFlip', prob=0.5), | ||
dict(type='PhotoMetricDistortion'), | ||
dict(type='Normalize', **img_norm_cfg), | ||
dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255), | ||
dict(type='DefaultFormatBundle'), | ||
dict(type='Collect', keys=['img', 'gt_semantic_seg']), | ||
] | ||
test_pipeline = [ | ||
dict(type='LoadImageFromFile'), | ||
dict( | ||
type='MultiScaleFlipAug', | ||
img_scale=img_scale, | ||
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75], | ||
flip=False, | ||
transforms=[ | ||
dict(type='Resize', keep_ratio=True), | ||
dict(type='RandomFlip'), | ||
dict(type='Normalize', **img_norm_cfg), | ||
dict(type='ImageToTensor', keys=['img']), | ||
dict(type='Collect', keys=['img']), | ||
]) | ||
] | ||
data = dict( | ||
samples_per_gpu=4, | ||
workers_per_gpu=4, | ||
train=dict( | ||
type=dataset_type, | ||
data_root=data_root, | ||
img_dir='JPEGImages', | ||
ann_dir='SegmentationClassContext', | ||
split='ImageSets/SegmentationContext/train.txt', | ||
pipeline=train_pipeline), | ||
val=dict( | ||
type=dataset_type, | ||
data_root=data_root, | ||
img_dir='JPEGImages', | ||
ann_dir='SegmentationClassContext', | ||
split='ImageSets/SegmentationContext/val.txt', | ||
pipeline=test_pipeline), | ||
test=dict( | ||
type=dataset_type, | ||
data_root=data_root, | ||
img_dir='JPEGImages', | ||
ann_dir='SegmentationClassContext', | ||
split='ImageSets/SegmentationContext/val.txt', | ||
pipeline=test_pipeline)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# optimizer | ||
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005) | ||
optimizer_config = dict() | ||
# learning policy | ||
lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False) | ||
# runtime settings | ||
runner = dict(type='IterBasedRunner', max_iters=160000) | ||
checkpoint_config = dict(by_epoch=True, interval=16000) | ||
evaluation = dict(interval=16000, metric='mIoU') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# optimizer | ||
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005) | ||
optimizer_config = dict() | ||
# learning policy | ||
lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=True) | ||
# runtime settings | ||
runner = dict(type='IterBasedRunner', max_iters=20000) | ||
checkpoint_config = dict(by_epoch=True, interval=2000) | ||
evaluation = dict(interval=2000, metric='mIoU') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# optimizer | ||
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005) | ||
optimizer_config = dict() | ||
# learning policy | ||
lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=True) | ||
# runtime settings | ||
runner = dict(type='IterBasedRunner', max_iters=40000) | ||
checkpoint_config = dict(by_epoch=True, interval=4000) | ||
evaluation = dict(interval=4000, metric='mIoU') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# optimizer | ||
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005) | ||
optimizer_config = dict() | ||
# learning policy | ||
lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False) | ||
# runtime settings | ||
runner = dict(type='IterBasedRunner', max_iters=80000) | ||
checkpoint_config = dict(by_epoch=True, interval=8000) | ||
evaluation = dict(interval=8000, metric='mIoU') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
_base_ = [ | ||
'../_base_/models/fcn_r50-d8.py', | ||
'../_base_/datasets/pascal_context_59.py', '../_base_/default_runtime.py', | ||
'../_base_/schedules/schedule_40k.py' | ||
] | ||
model = dict( | ||
decode_head=dict(num_classes=59), | ||
test_cfg=dict(mode='slide', crop_size=(480, 480), stride=(320, 320))) | ||
optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
_base_ = [ | ||
'../_base_/models/fcn_hr18.py', '../_base_/datasets/pascal_context_59.py', | ||
'../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py' | ||
] | ||
model = dict( | ||
decode_head=dict(num_classes=59), | ||
test_cfg=dict(mode='slide', crop_size=(480, 480), stride=(320, 320))) | ||
optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
_base_ = [ | ||
'../_base_/models/fcn_hr18.py', '../_base_/datasets/pascal_context_59.py', | ||
'../_base_/default_runtime.py', '../_base_/schedules/schedule_80k.py' | ||
] | ||
model = dict( | ||
decode_head=dict(num_classes=59), | ||
test_cfg=dict(mode='slide', crop_size=(480, 480), stride=(320, 320))) | ||
optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
_base_ = './fcn_hr18_480x480_40k_pascal_context_59.py' | ||
model = dict( | ||
pretrained='open-mmlab://msra/hrnetv2_w18_small', | ||
backbone=dict( | ||
extra=dict( | ||
stage1=dict(num_blocks=(2, )), | ||
stage2=dict(num_blocks=(2, 2)), | ||
stage3=dict(num_modules=3, num_blocks=(2, 2, 2)), | ||
stage4=dict(num_modules=2, num_blocks=(2, 2, 2, 2))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
_base_ = './fcn_hr18_480x480_80k_pascal_context_59.py' | ||
model = dict( | ||
pretrained='open-mmlab://msra/hrnetv2_w18_small', | ||
backbone=dict( | ||
extra=dict( | ||
stage1=dict(num_blocks=(2, )), | ||
stage2=dict(num_blocks=(2, 2)), | ||
stage3=dict(num_modules=3, num_blocks=(2, 2, 2)), | ||
stage4=dict(num_modules=2, num_blocks=(2, 2, 2, 2))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
_base_ = './fcn_hr18_480x480_40k_pascal_context_59.py' | ||
model = dict( | ||
pretrained='open-mmlab://msra/hrnetv2_w48', | ||
backbone=dict( | ||
extra=dict( | ||
stage2=dict(num_channels=(48, 96)), | ||
stage3=dict(num_channels=(48, 96, 192)), | ||
stage4=dict(num_channels=(48, 96, 192, 384)))), | ||
decode_head=dict( | ||
in_channels=[48, 96, 192, 384], channels=sum([48, 96, 192, 384]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
_base_ = './fcn_hr18_480x480_80k_pascal_context_59.py' | ||
model = dict( | ||
pretrained='open-mmlab://msra/hrnetv2_w48', | ||
backbone=dict( | ||
extra=dict( | ||
stage2=dict(num_channels=(48, 96)), | ||
stage3=dict(num_channels=(48, 96, 192)), | ||
stage4=dict(num_channels=(48, 96, 192, 384)))), | ||
decode_head=dict( | ||
in_channels=[48, 96, 192, 384], channels=sum([48, 96, 192, 384]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1411,6 +1411,13 @@ | |
} | ||
} | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters