From d6051382f1551455b88ca086b99275cfc8286131 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 17 Jun 2022 18:37:08 +0200 Subject: [PATCH] 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> --- utils/dataloaders.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/utils/dataloaders.py b/utils/dataloaders.py index 826bb998d7c2..51d1612d3d5d 100755 --- a/utils/dataloaders.py +++ b/utils/dataloaders.py @@ -1027,10 +1027,14 @@ def _hub_ops(f, max_dim=1920): 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