Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
4ffc28c9
Commit
4ffc28c9
authored
Feb 12, 2019
by
Michael Kösel
Committed by
Francisco Massa
Feb 12, 2019
Browse files
Small API cleanup to Cityscapes (#725)
parent
ef5b3dad
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
torchvision/datasets/cityscapes.py
torchvision/datasets/cityscapes.py
+13
-13
No files found.
torchvision/datasets/cityscapes.py
View file @
4ffc28c9
...
...
@@ -26,7 +26,7 @@ class Cityscapes(data.Dataset):
Get semantic segmentation target
.. code-block:: python
dataset = Cityscapes('./data/cityscapes', split='train', mode='
gtF
ine',
dataset = Cityscapes('./data/cityscapes', split='train', mode='
f
ine',
target_type='semantic')
img, smnt = dataset[0]
...
...
@@ -34,41 +34,41 @@ class Cityscapes(data.Dataset):
Get multiple targets
.. code-block:: python
dataset = Cityscapes('./data/cityscapes', split='train', mode='
gtF
ine',
dataset = Cityscapes('./data/cityscapes', split='train', mode='
f
ine',
target_type=['instance', 'color', 'polygon'])
img, (inst, col, poly) = dataset[0]
Validate on the "
gtC
oarse" set
Validate on the "
c
oarse" set
.. code-block:: python
dataset = Cityscapes('./data/cityscapes', split='val', mode='
gtC
oarse',
dataset = Cityscapes('./data/cityscapes', split='val', mode='
c
oarse',
target_type='semantic')
img, smnt = dataset[0]
"""
def
__init__
(
self
,
root
,
split
=
'train'
,
mode
=
'
gtF
ine'
,
target_type
=
'instance'
,
def
__init__
(
self
,
root
,
split
=
'train'
,
mode
=
'
f
ine'
,
target_type
=
'instance'
,
transform
=
None
,
target_transform
=
None
):
self
.
root
=
os
.
path
.
expanduser
(
root
)
self
.
mode
=
'gtFine'
if
mode
==
'fine'
else
'gtCoarse'
self
.
images_dir
=
os
.
path
.
join
(
self
.
root
,
'leftImg8bit'
,
split
)
self
.
targets_dir
=
os
.
path
.
join
(
self
.
root
,
mode
,
split
)
self
.
targets_dir
=
os
.
path
.
join
(
self
.
root
,
self
.
mode
,
split
)
self
.
transform
=
transform
self
.
target_transform
=
target_transform
self
.
target_type
=
target_type
self
.
split
=
split
self
.
mode
=
mode
self
.
images
=
[]
self
.
targets
=
[]
if
mode
not
in
[
'
gtF
ine'
,
'
gtC
oarse'
]:
raise
ValueError
(
'Invalid mode! Please use mode="
gtF
ine" or mode="
gtC
oarse"'
)
if
mode
not
in
[
'
f
ine'
,
'
c
oarse'
]:
raise
ValueError
(
'Invalid mode! Please use mode="
f
ine" or mode="
c
oarse"'
)
if
mode
==
'
gtF
ine'
and
split
not
in
[
'train'
,
'test'
,
'val'
]:
raise
ValueError
(
'Invalid split for mode "
gtF
ine"! Please use split="train", split="test"'
if
mode
==
'
f
ine'
and
split
not
in
[
'train'
,
'test'
,
'val'
]:
raise
ValueError
(
'Invalid split for mode "
f
ine"! Please use split="train", split="test"'
' or split="val"'
)
elif
mode
==
'
gtC
oarse'
and
split
not
in
[
'train'
,
'train_extra'
,
'val'
]:
raise
ValueError
(
'Invalid split for mode "
gtC
oarse"! Please use split="train", split="train_extra"'
elif
mode
==
'
c
oarse'
and
split
not
in
[
'train'
,
'train_extra'
,
'val'
]:
raise
ValueError
(
'Invalid split for mode "
c
oarse"! Please use split="train", split="train_extra"'
' or split="val"'
)
if
not
isinstance
(
target_type
,
list
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment