Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 63 additions & 34 deletions pipelines/local_configs/__base__/datasets/easyportrait_1024x1024.py
Original file line number Diff line number Diff line change
@@ -1,59 +1,88 @@
# dataset settings
dataset_type = 'EasyPortraitDataset'
data_root = 'path/to/data/EasyPortrait'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
dataset_type = 'EasyPortraitFPDataset'
data_root = 'data/easyportrait/'
crop_size = (1024, 1024)

train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations'),
dict(type='Pad', size=(1920, 1920), pad_val=0, seg_pad_val=255),
dict(type='Resize', img_scale=(1024, 1024)),
dict(
type='RandomResize',
scale=(1024, 1024),
ratio_range=(1.0, 1.0), # keep the aspect ratio
keep_ratio=True),


dict(type='RandomCrop', crop_size=crop_size),
# We don't use RandomFlip, but need it in the code to fix error: https://github.com/open-mmlab/mmsegmentation/issues/231
dict(type='RandomFlip', prob=0.0),
dict(type='RandomFlip', prob=0.0),
dict(type='PhotoMetricDistortion',
brightness_delta=16,
contrast_range=(0.5, 1.0),
saturation_range=(0.5, 1.0),
hue_delta=9),
dict(type='Normalize', **img_norm_cfg),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_semantic_seg']),
hue_delta=9),
dict(type='PackSegInputs')
]

test_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='Resize', scale=(1024, 1024), keep_ratio=True),
dict(type='LoadAnnotations'),
dict(type='PackSegInputs')

]

img_ratios = [0.5, 0.75, 1.0, 1.25, 1.5, 1.75]
tta_pipeline = [
dict(type='LoadImageFromFile', backend_args=None),
dict(
type='MultiScaleFlipAug',
img_scale=(1024, 1024),
flip=False,
type='TestTimeAug',
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='Normalize', **img_norm_cfg),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img']),
[
dict(type='Resize', scale_factor=r, keep_ratio=True)
for r in img_ratios
],
[
dict(type='RandomFlip', prob=0., direction='horizontal'),
dict(type='RandomFlip', prob=1., direction='horizontal')
], [dict(type='LoadAnnotations')], [dict(type='PackSegInputs')]
])
]

data = dict(
samples_per_gpu=4,
workers_per_gpu=4,
train=dict(
train_dataloader = dict(
# Increased batch size, maximmum on the
batch_size=4,
num_workers=4,
persistent_workers=True,
sampler=dict(type='InfiniteSampler', shuffle=True),
dataset=dict(
type=dataset_type,
data_root=data_root,
img_dir='images/train',
ann_dir='annotations/train',
pipeline=train_pipeline),
val=dict(
data_prefix=dict(
img_path='images/train', seg_map_path='annotations/train'),
pipeline=train_pipeline))

val_dataloader = dict(
batch_size=1,
num_workers=4,
persistent_workers=True,
sampler=dict(type='DefaultSampler', shuffle=False), # Do not shuffle during validation
dataset=dict(
type=dataset_type,
data_root=data_root,
img_dir='images/val',
ann_dir='annotations/val',
pipeline=test_pipeline),
test=dict(
data_prefix=dict(
img_path='images/val', seg_map_path='annotations/val'),
pipeline=test_pipeline))
test_dataloader = dict(
batch_size=1,
num_workers=4,
persistent_workers=True,
sampler=dict(type='DefaultSampler', shuffle=False), # Do not shuffle during validation
dataset=dict(
type=dataset_type,
data_root=data_root,
img_dir='images/test',
ann_dir='annotations/test',
pipeline=test_pipeline))
data_prefix=dict(
img_path='images/test', seg_map_path='annotations/test'),
pipeline=test_pipeline))

val_evaluator = dict(type='IoUMetric', iou_metrics=['mIoU']) # metric to measure the accuracy (mean IoU)
test_evaluator = val_evaluator
95 changes: 62 additions & 33 deletions pipelines/local_configs/__base__/datasets/easyportrait_384x384.py
Original file line number Diff line number Diff line change
@@ -1,59 +1,88 @@
# dataset settings
dataset_type = 'EasyPortraitDataset'
data_root = 'path/to/data/EasyPortrait'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
dataset_type = 'EasyPortraitFPDataset'
data_root = 'data/easyportrait/'
crop_size = (384, 384)

train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations'),
dict(type='Pad', size=(1920, 1920), pad_val=0, seg_pad_val=255),
dict(type='Resize', img_scale=(384, 384)),
dict(
type='RandomResize',
scale=(384, 384),
ratio_range=(1.0, 1.0), # keep the aspect ratio
keep_ratio=True),


dict(type='RandomCrop', crop_size=crop_size),
# We don't use RandomFlip, but need it in the code to fix error: https://github.com/open-mmlab/mmsegmentation/issues/231
dict(type='RandomFlip', prob=0.0),
dict(type='PhotoMetricDistortion',
brightness_delta=16,
contrast_range=(0.5, 1.0),
saturation_range=(0.5, 1.0),
hue_delta=9),
dict(type='Normalize', **img_norm_cfg),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_semantic_seg']),
hue_delta=9),
dict(type='PackSegInputs')
]

test_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='Resize', scale=(384, 384), keep_ratio=True),
dict(type='LoadAnnotations'),
dict(type='PackSegInputs')

]

img_ratios = [0.5, 0.75, 1.0, 1.25, 1.5, 1.75]
tta_pipeline = [
dict(type='LoadImageFromFile', backend_args=None),
dict(
type='MultiScaleFlipAug',
img_scale=(384, 384),
flip=False,
type='TestTimeAug',
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='Normalize', **img_norm_cfg),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img']),
[
dict(type='Resize', scale_factor=r, keep_ratio=True)
for r in img_ratios
],
[
dict(type='RandomFlip', prob=0., direction='horizontal'),
dict(type='RandomFlip', prob=1., direction='horizontal')
], [dict(type='LoadAnnotations')], [dict(type='PackSegInputs')]
])
]

data = dict(
samples_per_gpu=4,
workers_per_gpu=4,
train=dict(
train_dataloader = dict(
# Increased batch size, maximmum on the
batch_size=4,
num_workers=4,
persistent_workers=True,
sampler=dict(type='InfiniteSampler', shuffle=True),
dataset=dict(
type=dataset_type,
data_root=data_root,
img_dir='images/train',
ann_dir='annotations/train',
pipeline=train_pipeline),
val=dict(
data_prefix=dict(
img_path='images/train', seg_map_path='annotations/train'),
pipeline=train_pipeline))

val_dataloader = dict(
batch_size=1,
num_workers=4,
persistent_workers=True,
sampler=dict(type='DefaultSampler', shuffle=False), # Do not shuffle during validation
dataset=dict(
type=dataset_type,
data_root=data_root,
img_dir='images/val',
ann_dir='annotations/val',
pipeline=test_pipeline),
test=dict(
data_prefix=dict(
img_path='images/val', seg_map_path='annotations/val'),
pipeline=test_pipeline))
test_dataloader = dict(
batch_size=1,
num_workers=4,
persistent_workers=True,
sampler=dict(type='DefaultSampler', shuffle=False), # Do not shuffle during validation
dataset=dict(
type=dataset_type,
data_root=data_root,
img_dir='images/test',
ann_dir='annotations/test',
pipeline=test_pipeline))
data_prefix=dict(
img_path='images/test', seg_map_path='annotations/test'),
pipeline=test_pipeline))

val_evaluator = dict(type='IoUMetric', iou_metrics=['mIoU']) # metric to measure the accuracy (mean IoU)
test_evaluator = val_evaluator
95 changes: 62 additions & 33 deletions pipelines/local_configs/__base__/datasets/easyportrait_512x512.py
Original file line number Diff line number Diff line change
@@ -1,59 +1,88 @@
# dataset settings
dataset_type = 'EasyPortraitDataset'
data_root = 'path/to/data/EasyPortrait'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
dataset_type = 'EasyPortraitFPDataset'
data_root = 'data/easyportrait/'
crop_size = (512, 512)

train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations'),
dict(type='Pad', size=(1920, 1920), pad_val=0, seg_pad_val=255),
dict(type='Resize', img_scale=(512, 512)),
dict(
type='RandomResize',
scale=(512, 512),
ratio_range=(1.0, 1.0), # keep the aspect ratio
keep_ratio=True),


dict(type='RandomCrop', crop_size=crop_size),
# We don't use RandomFlip, but need it in the code to fix error: https://github.com/open-mmlab/mmsegmentation/issues/231
dict(type='RandomFlip', prob=0.0),
dict(type='PhotoMetricDistortion',
brightness_delta=16,
contrast_range=(0.5, 1.0),
saturation_range=(0.5, 1.0),
hue_delta=9),
dict(type='Normalize', **img_norm_cfg),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_semantic_seg']),
hue_delta=9),
dict(type='PackSegInputs')
]

test_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='Resize', scale=(512, 512), keep_ratio=True),
dict(type='LoadAnnotations'),
dict(type='PackSegInputs')

]

img_ratios = [0.5, 0.75, 1.0, 1.25, 1.5, 1.75]
tta_pipeline = [
dict(type='LoadImageFromFile', backend_args=None),
dict(
type='MultiScaleFlipAug',
img_scale=(512, 512),
flip=False,
type='TestTimeAug',
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='Normalize', **img_norm_cfg),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img']),
[
dict(type='Resize', scale_factor=r, keep_ratio=True)
for r in img_ratios
],
[
dict(type='RandomFlip', prob=0., direction='horizontal'),
dict(type='RandomFlip', prob=1., direction='horizontal')
], [dict(type='LoadAnnotations')], [dict(type='PackSegInputs')]
])
]

data = dict(
samples_per_gpu=4,
workers_per_gpu=4,
train=dict(
train_dataloader = dict(
# Increased batch size, maximmum on the
batch_size=4,
num_workers=4,
persistent_workers=True,
sampler=dict(type='InfiniteSampler', shuffle=True),
dataset=dict(
type=dataset_type,
data_root=data_root,
img_dir='images/train',
ann_dir='annotations/train',
pipeline=train_pipeline),
val=dict(
data_prefix=dict(
img_path='images/train', seg_map_path='annotations/train'),
pipeline=train_pipeline))

val_dataloader = dict(
batch_size=1,
num_workers=4,
persistent_workers=True,
sampler=dict(type='DefaultSampler', shuffle=False), # Do not shuffle during validation
dataset=dict(
type=dataset_type,
data_root=data_root,
img_dir='images/val',
ann_dir='annotations/val',
pipeline=test_pipeline),
test=dict(
data_prefix=dict(
img_path='images/val', seg_map_path='annotations/val'),
pipeline=test_pipeline))
test_dataloader = dict(
batch_size=1,
num_workers=4,
persistent_workers=True,
sampler=dict(type='DefaultSampler', shuffle=False), # Do not shuffle during validation
dataset=dict(
type=dataset_type,
data_root=data_root,
img_dir='images/test',
ann_dir='annotations/test',
pipeline=test_pipeline))
data_prefix=dict(
img_path='images/test', seg_map_path='annotations/test'),
pipeline=test_pipeline))

val_evaluator = dict(type='IoUMetric', iou_metrics=['mIoU']) # metric to measure the accuracy (mean IoU)
test_evaluator = val_evaluator
Loading