From 2b26572e42a011c21a5eeb4af3333da89431609c Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 5 Jun 2023 01:37:36 +0200 Subject: [PATCH] Fix GlobalWheat2020.yaml auto download (#3007) --- ultralytics/datasets/GlobalWheat2020.yaml | 4 ++-- ultralytics/yolo/utils/downloads.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ultralytics/datasets/GlobalWheat2020.yaml b/ultralytics/datasets/GlobalWheat2020.yaml index de29aa74..533a0b7d 100644 --- a/ultralytics/datasets/GlobalWheat2020.yaml +++ b/ultralytics/datasets/GlobalWheat2020.yaml @@ -48,7 +48,7 @@ download: | # Move for p in 'arvalis_1', 'arvalis_2', 'arvalis_3', 'ethz_1', 'rres_1', 'inrae_1', 'usask_1', \ 'utokyo_1', 'utokyo_2', 'nau_1', 'uq_1': - (dir / p).rename(dir / 'images' / p) # move to /images - f = (dir / p).with_suffix('.json') # json file + (dir / 'global-wheat-codalab-official' / p).rename(dir / 'images' / p) # move to /images + f = (dir / 'global-wheat-codalab-official' / p).with_suffix('.json') # json file if f.exists(): f.rename((dir / 'annotations' / p).with_suffix('.json')) # move to /annotations diff --git a/ultralytics/yolo/utils/downloads.py b/ultralytics/yolo/utils/downloads.py index a3f661de..c69b18ff 100644 --- a/ultralytics/yolo/utils/downloads.py +++ b/ultralytics/yolo/utils/downloads.py @@ -131,9 +131,10 @@ def safe_download(url, a successful download. Default: 1E0. progress (bool, optional): Whether to display a progress bar during the download. Default: True. """ - if '://' not in str(url) and Path(url).is_file(): # exists ('://' check required in Windows Python<3.10) + f = dir / url2file(url) if dir else Path(file) # URL converted to filename + if '://' not in str(url) and Path(url).is_file(): # URL exists ('://' check required in Windows Python<3.10) f = Path(url) # filename - else: # does not exist + elif not f.is_file(): # URL and file do not exist assert dir or file, 'dir or file required for download' f = dir / url2file(url) if dir else Path(file) desc = f'Downloading {clean_url(url)} to {f}'