From 886e4ca59b0e37b7411c3f47ee5c3d10c43bc37f Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 13 Jun 2022 12:34:59 +0200 Subject: [PATCH 1/3] HUB dataset_stats() error reporting --- utils/dataloaders.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/utils/dataloaders.py b/utils/dataloaders.py index 4690f0c2e81e..0db497200fae 100755 --- a/utils/dataloaders.py +++ b/utils/dataloaders.py @@ -1024,10 +1024,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 as e: + 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 From 3d5bbd7aa5f889e2cda6a87925261bff0f207a26 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jun 2022 10:35:23 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- utils/dataloaders.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/dataloaders.py b/utils/dataloaders.py index 0db497200fae..0fb838976ecc 100755 --- a/utils/dataloaders.py +++ b/utils/dataloaders.py @@ -1028,7 +1028,7 @@ def _hub_ops(f, max_dim=1920): 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()?` + data['path'] = data_dir # TODO: should this be dir.resolve()?` except Exception as e: raise Exception("error/HUB/dataset_stats/yaml_load") From 4748a0b5a3f69caf801b16d17eab3e1d399f2a67 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 13 Jun 2022 15:14:21 +0200 Subject: [PATCH 3/3] Update dataloaders.py --- utils/dataloaders.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/dataloaders.py b/utils/dataloaders.py index 0fb838976ecc..14ee1ce558d1 100755 --- a/utils/dataloaders.py +++ b/utils/dataloaders.py @@ -1029,7 +1029,7 @@ def _hub_ops(f, max_dim=1920): data = yaml.safe_load(f) # data dict if zipped: data['path'] = data_dir # TODO: should this be dir.resolve()?` - except Exception as e: + except Exception: raise Exception("error/HUB/dataset_stats/yaml_load") check_dataset(data, autodownload) # download dataset if missing