HUB dataset_stats() error reporting (#8192)
Browse files* 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>
- utils/dataloaders.py +8 -4
utils/dataloaders.py
CHANGED
@@ -1027,10 +1027,14 @@ def dataset_stats(path='coco128.yaml', autodownload=False, verbose=False, profil
|
|
1027 |
cv2.imwrite(str(f_new), im)
|
1028 |
|
1029 |
zipped, data_dir, yaml_path = _unzip(Path(path))
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
|
|
|
|
|
|
|
|
1034 |
check_dataset(data, autodownload) # download dataset if missing
|
1035 |
hub_dir = Path(data['path'] + ('-hub' if hub else ''))
|
1036 |
stats = {'nc': data['nc'], 'names': data['names']} # statistics dictionary
|
|
|
1027 |
cv2.imwrite(str(f_new), im)
|
1028 |
|
1029 |
zipped, data_dir, yaml_path = _unzip(Path(path))
|
1030 |
+
try:
|
1031 |
+
with open(check_yaml(yaml_path), errors='ignore') as f:
|
1032 |
+
data = yaml.safe_load(f) # data dict
|
1033 |
+
if zipped:
|
1034 |
+
data['path'] = data_dir # TODO: should this be dir.resolve()?`
|
1035 |
+
except Exception:
|
1036 |
+
raise Exception("error/HUB/dataset_stats/yaml_load")
|
1037 |
+
|
1038 |
check_dataset(data, autodownload) # download dataset if missing
|
1039 |
hub_dir = Path(data['path'] + ('-hub' if hub else ''))
|
1040 |
stats = {'nc': data['nc'], 'names': data['names']} # statistics dictionary
|