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

Update `check_datasets()` for dynamic unzip path (#3732)

@KalenMike
上级 9ac7d388
...@@ -223,16 +223,17 @@ def check_file(file): ...@@ -223,16 +223,17 @@ def check_file(file):
def check_dataset(data, autodownload=True): def check_dataset(data, autodownload=True):
# Download dataset if not found locally # Download dataset if not found locally
val, s = data.get('val'), data.get('download') val, s = data.get('val'), data.get('download')
if val and len(val): if val:
root = Path(val).parts[0] + os.sep # unzip directory i.e. '../'
val = [Path(x).resolve() for x in (val if isinstance(val, list) else [val])] # val path val = [Path(x).resolve() for x in (val if isinstance(val, list) else [val])] # val path
if not all(x.exists() for x in val): if not all(x.exists() for x in val):
print('\nWARNING: Dataset not found, nonexistent paths: %s' % [str(x) for x in val if not x.exists()]) print('\nWARNING: Dataset not found, nonexistent paths: %s' % [str(x) for x in val if not x.exists()])
if s and len(s) and autodownload: # download script if s and autodownload: # download script
if s.startswith('http') and s.endswith('.zip'): # URL if s.startswith('http') and s.endswith('.zip'): # URL
f = Path(s).name # filename f = Path(s).name # filename
print(f'Downloading {s} ...') print(f'Downloading {s} ...')
torch.hub.download_url_to_file(s, f) torch.hub.download_url_to_file(s, f)
r = os.system(f'unzip -q {f} -d ../ && rm {f}') # unzip r = os.system(f'unzip -q {f} -d {root} && rm {f}') # unzip
elif s.startswith('bash '): # bash script elif s.startswith('bash '): # bash script
print(f'Running {s} ...') print(f'Running {s} ...')
r = os.system(s) r = os.system(s)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论