@@ -26,49 +26,49 @@ class Cityscapes(data.Dataset):
26
26
Get semantic segmentation target
27
27
28
28
.. code-block:: python
29
- dataset = Cityscapes('./data/cityscapes', split='train', mode='gtFine ',
29
+ dataset = Cityscapes('./data/cityscapes', split='train', mode='fine ',
30
30
target_type='semantic')
31
31
32
32
img, smnt = dataset[0]
33
33
34
34
Get multiple targets
35
35
36
36
.. code-block:: python
37
- dataset = Cityscapes('./data/cityscapes', split='train', mode='gtFine ',
37
+ dataset = Cityscapes('./data/cityscapes', split='train', mode='fine ',
38
38
target_type=['instance', 'color', 'polygon'])
39
39
40
40
img, (inst, col, poly) = dataset[0]
41
41
42
- Validate on the "gtCoarse " set
42
+ Validate on the "coarse " set
43
43
44
44
.. code-block:: python
45
- dataset = Cityscapes('./data/cityscapes', split='val', mode='gtCoarse ',
45
+ dataset = Cityscapes('./data/cityscapes', split='val', mode='coarse ',
46
46
target_type='semantic')
47
47
48
48
img, smnt = dataset[0]
49
49
"""
50
50
51
- def __init__ (self , root , split = 'train' , mode = 'gtFine ' , target_type = 'instance' ,
51
+ def __init__ (self , root , split = 'train' , mode = 'fine ' , target_type = 'instance' ,
52
52
transform = None , target_transform = None ):
53
53
self .root = os .path .expanduser (root )
54
+ self .mode = 'gtFine' if mode == 'fine' else 'gtCoarse'
54
55
self .images_dir = os .path .join (self .root , 'leftImg8bit' , split )
55
- self .targets_dir = os .path .join (self .root , mode , split )
56
+ self .targets_dir = os .path .join (self .root , self . mode , split )
56
57
self .transform = transform
57
58
self .target_transform = target_transform
58
59
self .target_type = target_type
59
60
self .split = split
60
- self .mode = mode
61
61
self .images = []
62
62
self .targets = []
63
63
64
- if mode not in ['gtFine ' , 'gtCoarse ' ]:
65
- raise ValueError ('Invalid mode! Please use mode="gtFine " or mode="gtCoarse "' )
64
+ if mode not in ['fine ' , 'coarse ' ]:
65
+ raise ValueError ('Invalid mode! Please use mode="fine " or mode="coarse "' )
66
66
67
- if mode == 'gtFine ' and split not in ['train' , 'test' , 'val' ]:
68
- raise ValueError ('Invalid split for mode "gtFine "! Please use split="train", split="test"'
67
+ if mode == 'fine ' and split not in ['train' , 'test' , 'val' ]:
68
+ raise ValueError ('Invalid split for mode "fine "! Please use split="train", split="test"'
69
69
' or split="val"' )
70
- elif mode == 'gtCoarse ' and split not in ['train' , 'train_extra' , 'val' ]:
71
- raise ValueError ('Invalid split for mode "gtCoarse "! Please use split="train", split="train_extra"'
70
+ elif mode == 'coarse ' and split not in ['train' , 'train_extra' , 'val' ]:
71
+ raise ValueError ('Invalid split for mode "coarse "! Please use split="train", split="train_extra"'
72
72
' or split="val"' )
73
73
74
74
if not isinstance (target_type , list ):
0 commit comments