Curl update (#3004)

* Curl update

* Curl update
This commit is contained in:
Glenn Jocher authored and GitHub committed 2021-05-01 17:29:51 +02:00
1 parent 4d7bca7648
commit 37eaffec7d
3 files changed
+7 -4

No files matched your search

+5 -2
View File
@@ -183,14 +183,17 @@ def check_dataset(dict):
raise Exception('Dataset not found.')
def download(url, dir='.', unzip=True, threads=1):
def download(url, dir='.', unzip=True, curl=False, threads=1):
# Multi-threaded file download and unzip function
def download_one(url, dir):
# Download 1 file
f = dir / Path(url).name # filename
if not f.exists():
print(f'Downloading {url} to {f}...')
torch.hub.download_url_to_file(url, f, progress=True) # download
if curl:
os.system(f"curl -L '{url}' -o '{f}' --retry 9 -C -") # curl download, retry and resume on fail
else:
torch.hub.download_url_to_file(url, f, progress=True) # torch download
if unzip and f.suffix in ('.zip', '.gz'):
print(f'Unzipping {f}...')
if f.suffix == '.zip':