1 parent
4d7bca7648
commit
37eaffec7d
3 files changed
+7
-4
No files matched your search
+5
-2
@@ -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':
|
||||
|
||||
Reference in new issue
Block a user