Skip to content

[Bug] YOLODataset Initialization Crash on Missing 'test' Split #392

@karttikjangid

Description

@karttikjangid

While using the standard COCO8 dataset to verify an object detection pipeline, I found that the YOLODataset loader crashes during initialization if the data.yaml does not explicitly define a path for every split (specifically the test split).

In the YOLO ecosystem, many datasets (including COCO8 and various custom subsets) only provide train and val sets. Currently, the loader attempts to perform an os.path.join on the split paths without verifying if the keys exist in the YAML, leading to an unhandled TypeError.

Steps to Reproduce

The crash can be reproduced in any environment using the following minimal script with the standard COCO8 dataset:

import os
from perceptionmetrics.datasets.yolo import YOLODataset

# 1. Using the standard COCO8 dataset (missing 'test' split in YAML)
# Download: !wget -q [https://github.com/ultralytics/hub/raw/main/example_datasets/coco8.zip](https://github.com/ultralytics/hub/raw/main/example_datasets/coco8.zip)

# 2. Attempt to initialize the dataset
# This triggers the TypeError inside the constructor
dataset = YOLODataset("coco8/coco8.yaml", "coco8")

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions