Kalen Michael glenn-jocher commited on
Commit
76d301b
1 Parent(s): cd35a00

Fix URL parsing bug (#4998)

Browse files

* 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>

Files changed (1) hide show
  1. utils/general.py +1 -1
utils/general.py CHANGED
@@ -313,7 +313,7 @@ def check_file(file, suffix=''):
313
  return file
314
  elif file.startswith(('http:/', 'https:/')): # download
315
  url = str(Path(file)).replace(':/', '://') # Pathlib turns :// -> :/
316
- file = Path(urllib.parse.unquote(file)).name.split('?')[0] # '%2F' to '/', split https://url.com/file.txt?auth
317
  print(f'Downloading {url} to {file}...')
318
  torch.hub.download_url_to_file(url, file)
319
  assert Path(file).exists() and Path(file).stat().st_size > 0, f'File download failed: {url}' # check
 
313
  return file
314
  elif file.startswith(('http:/', 'https:/')): # download
315
  url = str(Path(file)).replace(':/', '://') # Pathlib turns :// -> :/
316
+ file = Path(urllib.parse.unquote(file).split('?')[0]).name # '%2F' to '/', split https://url.com/file.txt?auth
317
  print(f'Downloading {url} to {file}...')
318
  torch.hub.download_url_to_file(url, file)
319
  assert Path(file).exists() and Path(file).stat().st_size > 0, f'File download failed: {url}' # check