From 29ace4982dcd1d5c3c18e47e7d005e62279d9a1e Mon Sep 17 00:00:00 2001 From: Laughing <61612323+Laughing-q@users.noreply.github.com> Date: Thu, 10 Aug 2023 06:15:14 +0800 Subject: [PATCH] Add "assert len(labels)" catch (#4257) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher --- ultralytics/data/dataset.py | 1 + ultralytics/data/utils.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ultralytics/data/dataset.py b/ultralytics/data/dataset.py index 575243f..1d13261 100644 --- a/ultralytics/data/dataset.py +++ b/ultralytics/data/dataset.py @@ -126,6 +126,7 @@ class YOLODataset(BaseDataset): # Read cache [cache.pop(k) for k in ('hash', 'version', 'msgs')] # remove items labels = cache['labels'] + assert len(labels), f'No valid labels found, please check your dataset. {HELP_URL}' self.im_files = [lb['im_file'] for lb in labels] # update im_files # Check if the dataset is all boxes or all segments diff --git a/ultralytics/data/utils.py b/ultralytics/data/utils.py index 561b994..807ddad 100644 --- a/ultralytics/data/utils.py +++ b/ultralytics/data/utils.py @@ -24,7 +24,7 @@ from ultralytics.utils.checks import check_file, check_font, is_ascii from ultralytics.utils.downloads import download, safe_download, unzip_file from ultralytics.utils.ops import segments2boxes -HELP_URL = 'See https://docs.ultralytics.com/yolov5/tutorials/train_custom_data' +HELP_URL = 'See https://docs.ultralytics.com/datasets/detect for YOLO dataset format help.' IMG_FORMATS = 'bmp', 'dng', 'jpeg', 'jpg', 'mpo', 'png', 'tif', 'tiff', 'webp', 'pfm' # image suffixes VID_FORMATS = 'asf', 'avi', 'gif', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'ts', 'wmv', 'webm' # video suffixes PIN_MEMORY = str(os.getenv('PIN_MEMORY', True)).lower() == 'true' # global pin_memory for dataloaders