glenn-jocher
commited on
Commit
•
4d7bca7
1
Parent(s):
f55730e
Add unzip flag to download() (#3002)
Browse files- utils/general.py +2 -2
utils/general.py
CHANGED
@@ -183,7 +183,7 @@ def check_dataset(dict):
|
|
183 |
raise Exception('Dataset not found.')
|
184 |
|
185 |
|
186 |
-
def download(url, dir='.', threads=1):
|
187 |
# Multi-threaded file download and unzip function
|
188 |
def download_one(url, dir):
|
189 |
# Download 1 file
|
@@ -191,7 +191,7 @@ def download(url, dir='.', threads=1):
|
|
191 |
if not f.exists():
|
192 |
print(f'Downloading {url} to {f}...')
|
193 |
torch.hub.download_url_to_file(url, f, progress=True) # download
|
194 |
-
if f.suffix in ('.zip', '.gz'):
|
195 |
print(f'Unzipping {f}...')
|
196 |
if f.suffix == '.zip':
|
197 |
os.system(f'unzip -qo {f} -d {dir} && rm {f}') # unzip -quiet -overwrite
|
|
|
183 |
raise Exception('Dataset not found.')
|
184 |
|
185 |
|
186 |
+
def download(url, dir='.', unzip=True, threads=1):
|
187 |
# Multi-threaded file download and unzip function
|
188 |
def download_one(url, dir):
|
189 |
# Download 1 file
|
|
|
191 |
if not f.exists():
|
192 |
print(f'Downloading {url} to {f}...')
|
193 |
torch.hub.download_url_to_file(url, f, progress=True) # download
|
194 |
+
if unzip and f.suffix in ('.zip', '.gz'):
|
195 |
print(f'Unzipping {f}...')
|
196 |
if f.suffix == '.zip':
|
197 |
os.system(f'unzip -qo {f} -d {dir} && rm {f}') # unzip -quiet -overwrite
|