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
4c56f429
Commit
4c56f429
authored
Jul 01, 2019
by
Ross Taylor
Committed by
Francisco Massa
Jul 01, 2019
Browse files
Using datasets.utils extract function; accounting for train_extra dataset unzipping (#1068)
parent
867e5b4e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
9 deletions
+7
-9
torchvision/datasets/cityscapes.py
torchvision/datasets/cityscapes.py
+7
-9
No files found.
torchvision/datasets/cityscapes.py
View file @
4c56f429
...
...
@@ -3,6 +3,7 @@ import os
from
collections
import
namedtuple
import
zipfile
from
.utils
import
extract_archive
from
.vision
import
VisionDataset
from
PIL
import
Image
...
...
@@ -126,7 +127,10 @@ class Cityscapes(VisionDataset):
' or "color"'
)
if
not
os
.
path
.
isdir
(
self
.
images_dir
)
or
not
os
.
path
.
isdir
(
self
.
targets_dir
):
image_dir_zip
=
os
.
path
.
join
(
self
.
root
,
'leftImg8bit'
)
+
'_trainvaltest.zip'
if
split
==
'train_extra'
:
image_dir_zip
=
os
.
path
.
join
(
self
.
root
,
'leftImg8bit'
)
+
'_trainextra.zip'
else
:
image_dir_zip
=
os
.
path
.
join
(
self
.
root
,
'leftImg8bit'
)
+
'_trainvaltest.zip'
if
self
.
mode
==
'gtFine'
:
target_dir_zip
=
os
.
path
.
join
(
self
.
root
,
self
.
mode
)
+
'_trainvaltest.zip'
...
...
@@ -134,8 +138,8 @@ class Cityscapes(VisionDataset):
target_dir_zip
=
os
.
path
.
join
(
self
.
root
,
self
.
mode
)
if
os
.
path
.
isfile
(
image_dir_zip
)
and
os
.
path
.
isfile
(
target_dir_zip
):
extract_
cityscapes_zip
(
zip_location
=
image_dir_zip
,
root
=
self
.
root
)
extract_
cityscapes_zip
(
zip_location
=
target_dir_zip
,
root
=
self
.
root
)
extract_
archive
(
from_path
=
image_dir_zip
,
to_path
=
self
.
root
)
extract_
archive
(
from_path
=
target_dir_zip
,
to_path
=
self
.
root
)
else
:
raise
RuntimeError
(
'Dataset not found or incomplete. Please make sure all required folders for the'
' specified "split" and "mode" are inside the "root" directory'
)
...
...
@@ -201,9 +205,3 @@ class Cityscapes(VisionDataset):
return
'{}_color.png'
.
format
(
mode
)
else
:
return
'{}_polygons.json'
.
format
(
mode
)
def
extract_cityscapes_zip
(
zip_location
,
root
):
zip_file
=
zipfile
.
ZipFile
(
zip_location
,
'r'
)
zip_file
.
extractall
(
root
)
zip_file
.
close
()
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