Missing nc and names handling in check_dataset() (#4066)

This commit is contained in:
Glenn Jocher 2021-07-19 13:10:21 +02:00 committed by GitHub
parent b1be685005
commit c8a98cb7cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -231,6 +231,9 @@ def check_dataset(data, autodownload=True):
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]]
assert 'nc' in data, "Dataset 'nc' key missing."
if 'names' not in data:
data['names'] = [str(i) for i in range(data['nc'])] # assign class names if missing
train, val, test, s = [data.get(x) for x in ('train', 'val', 'test', 'download')]
if val:
val = [Path(x).resolve() for x in (val if isinstance(val, list) else [val])] # val path