Unverified 提交 76d301bd authored 作者: Kalen Michael's avatar Kalen Michael 提交者: GitHub

Fix URL parsing bug (#4998)

* added callbacks * added back callback to main * added save_dir to callback output * merged in upstream * removed ghost code * fixed parsing error for google temp links Co-authored-by: 's avatarGlenn Jocher <glenn.jocher@ultralytics.com>
上级 cd35a009
...@@ -313,7 +313,7 @@ def check_file(file, suffix=''): ...@@ -313,7 +313,7 @@ def check_file(file, suffix=''):
return file return file
elif file.startswith(('http:/', 'https:/')): # download elif file.startswith(('http:/', 'https:/')): # download
url = str(Path(file)).replace(':/', '://') # Pathlib turns :// -> :/ url = str(Path(file)).replace(':/', '://') # Pathlib turns :// -> :/
file = Path(urllib.parse.unquote(file)).name.split('?')[0] # '%2F' to '/', split https://url.com/file.txt?auth file = Path(urllib.parse.unquote(file).split('?')[0]).name # '%2F' to '/', split https://url.com/file.txt?auth
print(f'Downloading {url} to {file}...') print(f'Downloading {url} to {file}...')
torch.hub.download_url_to_file(url, file) torch.hub.download_url_to_file(url, file)
assert Path(file).exists() and Path(file).stat().st_size > 0, f'File download failed: {url}' # check assert Path(file).exists() and Path(file).stat().st_size > 0, f'File download failed: {url}' # check
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论