Skip to content

Commit c0f078c

Browse files
authored
Resolve dataset paths (ultralytics#6489)
1 parent 5a29551 commit c0f078c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

utils/general.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,15 @@ def check_dataset(data, autodownload=True):
394394
with open(data, errors='ignore') as f:
395395
data = yaml.safe_load(f) # dictionary
396396

397-
# Parse yaml
398-
path = extract_dir or Path(data.get('path') or '') # optional 'path' default to '.'
397+
# Resolve paths
398+
path = Path(extract_dir or data.get('path') or '') # optional 'path' default to '.'
399+
if not path.is_absolute():
400+
path = (ROOT / path).resolve()
399401
for k in 'train', 'val', 'test':
400402
if data.get(k): # prepend path
401403
data[k] = str(path / data[k]) if isinstance(data[k], str) else [str(path / x) for x in data[k]]
402404

405+
# Parse yaml
403406
assert 'nc' in data, "Dataset 'nc' key missing."
404407
if 'names' not in data:
405408
data['names'] = [f'class{i}' for i in range(data['nc'])] # assign class names if missing

0 commit comments

Comments
 (0)