From e560a6ff270016b0740749d1e0548364d7ea3085 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 1 Feb 2022 15:42:32 +0100 Subject: [PATCH] Resolve dataset paths --- utils/general.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utils/general.py b/utils/general.py index e9f5ec2ac128..86e3b3c1c54b 100755 --- a/utils/general.py +++ b/utils/general.py @@ -394,12 +394,15 @@ def check_dataset(data, autodownload=True): with open(data, errors='ignore') as f: data = yaml.safe_load(f) # dictionary - # Parse yaml - path = extract_dir or Path(data.get('path') or '') # optional 'path' default to '.' + # Resolve paths + path = Path(extract_dir or data.get('path') or '') # optional 'path' default to '.' + if not path.is_absolute(): + path = (ROOT / path).resolve() for k in 'train', 'val', 'test': if data.get(k): # prepend path data[k] = str(path / data[k]) if isinstance(data[k], str) else [str(path / x) for x in data[k]] + # Parse yaml assert 'nc' in data, "Dataset 'nc' key missing." if 'names' not in data: data['names'] = [f'class{i}' for i in range(data['nc'])] # assign class names if missing