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: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Kalen MichaelandGlenn Jocher authored and GitHub committed 2021-09-29 10:48:45 -07:00
1 parent cd35a009ba
commit 76d301bd21
1 file changed
+1 -1
+1 -1
View File
@@ -313,7 +313,7 @@ def check_file(file, suffix=''):
return file
elif file.startswith(('http:/', 'https:/')): # download
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}...')
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