HUB dataset_stats() error reporting (#8192)
* HUB dataset_stats() error reporting * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update dataloaders.py Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>pull/8254/head
parent
303f3785ae
commit
d6051382f1
|
@ -1027,10 +1027,14 @@ def dataset_stats(path='coco128.yaml', autodownload=False, verbose=False, profil
|
|||
cv2.imwrite(str(f_new), im)
|
||||
|
||||
zipped, data_dir, yaml_path = _unzip(Path(path))
|
||||
with open(check_yaml(yaml_path), errors='ignore') as f:
|
||||
data = yaml.safe_load(f) # data dict
|
||||
if zipped:
|
||||
data['path'] = data_dir # TODO: should this be dir.resolve()?
|
||||
try:
|
||||
with open(check_yaml(yaml_path), errors='ignore') as f:
|
||||
data = yaml.safe_load(f) # data dict
|
||||
if zipped:
|
||||
data['path'] = data_dir # TODO: should this be dir.resolve()?`
|
||||
except Exception:
|
||||
raise Exception("error/HUB/dataset_stats/yaml_load")
|
||||
|
||||
check_dataset(data, autodownload) # download dataset if missing
|
||||
hub_dir = Path(data['path'] + ('-hub' if hub else ''))
|
||||
stats = {'nc': data['nc'], 'names': data['names']} # statistics dictionary
|
||||
|
|
Loading…
Reference in New Issue