Unverified 提交 45632b27 authored 作者: Glenn Jocher's avatar Glenn Jocher 提交者: GitHub

Update download() for tar.gz files (#2919)

* Update download() for tar.gz files * Update general.py
上级 1b1ab4cc
......@@ -184,14 +184,19 @@ def check_dataset(dict):
def download(url, dir='.', multi_thread=False):
# Multi-threaded file download function
# Multi-threaded file download and unzip function
def download_one(url, dir):
# Download 1 file
f = dir / Path(url).name # filename
print(f'Downloading {url} to {f}...')
torch.hub.download_url_to_file(url, f, progress=True) # download
if f.suffix == '.zip':
os.system(f'unzip -qo {f} -d {dir} && rm {f}') # unzip -quiet -overwrite
if not f.exists():
print(f'Downloading {url} to {f}...')
torch.hub.download_url_to_file(url, f, progress=True) # download
if f.suffix in ('.zip', '.gz'):
print(f'Unzipping {f}...')
if f.suffix == '.zip':
os.system(f'unzip -qo {f} -d {dir} && rm {f}') # unzip -quiet -overwrite
elif f.suffix == '.gz':
os.system(f'tar xfz {f} --directory {f.parent} && rm {f}') # unzip
dir = Path(dir)
dir.mkdir(parents=True, exist_ok=True) # make directory
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论