-
Notifications
You must be signed in to change notification settings - Fork 0
/
uda_gta_to_cityscapes_512x512.py
82 lines (81 loc) · 3.03 KB
/
uda_gta_to_cityscapes_512x512.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# ---------------------------------------------------------------
# Copyright (c) 2021-2022 ETH Zurich, Lukas Hoyer. All rights reserved.
# Licensed under the Apache License, Version 2.0
# ---------------------------------------------------------------
# dataset settings
# dataset settings
dataset_type = 'CityscapesDataset'
data_root = '/home/workspace/datasets/cityscapes/'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
crop_size = (512, 512)
gta_train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations'),
dict(type='Resize', img_scale=(1280, 720)),
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75),
dict(type='RandomFlip', prob=0.5),
# dict(type='PhotoMetricDistortion'), # is applied later in dacs.py
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']),
]
cityscapes_train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations'),
dict(type='Resize', img_scale=(1024, 512)),
dict(type='RandomCrop', crop_size=crop_size),
dict(type='RandomFlip', prob=0.5),
# dict(type='PhotoMetricDistortion'), # is applied later in dacs.py
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=(1024, 512),
# MultiScaleFlipAug is disabled by not providing img_ratios and
# setting flip=False
# 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=2,
workers_per_gpu=4,
train=dict(
type='UDADataset',
source=dict(
type='GTADataset',
data_root='/home/workspace/datasets/gta/',
img_dir='images',
ann_dir='labels',
pipeline=gta_train_pipeline),
target=dict(
type='CityscapesDataset',
data_root='/home/workspace/datasets/cityscapes/',
img_dir='leftImg8bit/train',
ann_dir='gtFine/train',
pipeline=cityscapes_train_pipeline)),
val=dict(
type='CityscapesDataset',
data_root='/home/workspace/datasets/cityscapes/',
img_dir='leftImg8bit/val',
ann_dir='gtFine/val',
pipeline=test_pipeline),
test=dict(
type='CityscapesDataset',
data_root='/home/workspace/datasets/cityscapes/',
img_dir='leftImg8bit/val',
ann_dir='gtFine/val',
pipeline=test_pipeline))