Commit 4c56f429 authored by Ross Taylor's avatar Ross Taylor Committed by Francisco Massa
Browse files

Using datasets.utils extract function; accounting for train_extra dataset unzipping (#1068)

parent 867e5b4e
......@@ -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()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment