Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding command line arguments to download-dataset tool #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions tools/download-dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,27 @@
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen # python 3
import sys
import tarfile
import tempfile
import shutil
import os
import argparse

dataset = sys.argv[1]
url = "https://people.eecs.berkeley.edu/~tinghuiz/projects/pix2pix/datasets/%s.tar.gz" % dataset

parser = argparse.ArgumentParser()
parser.add_argument("dataset", default="facades", help="name of the dataset to download: cityscapes edges2handbags"
"edges2shoes, facades, maps")
parser.add_argument("--save_dir", default=".", help="path to save the images")
a = parser.parse_args()

url = "https://people.eecs.berkeley.edu/~tinghuiz/projects/pix2pix/datasets/%s.tar.gz" % a.dataset
with tempfile.TemporaryFile() as tmp:
print("downloading", url)
shutil.copyfileobj(urlopen(url), tmp)
print("extracting")
tmp.seek(0)
tar = tarfile.open(fileobj=tmp)
os.chdir(a.save_dir)
tar.extractall()
tar.close()
print("done")