Skip to content

Handle missing detection/segmentation label files#587

Merged
guarin merged 8 commits intomainfrom
handle-missing-label-files
Feb 5, 2026
Merged

Handle missing detection/segmentation label files#587
guarin merged 8 commits intomainfrom
handle-missing-label-files

Conversation

@guarin
Copy link
Contributor

@guarin guarin commented Jan 29, 2026

What has changed and why?

  • Add option to skip missing label files
  • Treat missing label files by default as having no annotations

Follow up from #580

How has it been tested?

  • Manually

Did you update CHANGELOG.md?

  • Yes
  • Not needed (internal change)

Did you update the documentation?

  • Yes
  • Not needed (internal change without effects for user)

Copilot AI review requested due to automatic review settings January 29, 2026 10:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for YOLO object detection and instance segmentation datasets to handle missing label files more gracefully by defaulting to “no annotations” and optionally skipping samples without labels.

Changes:

  • Treat missing YOLO label files as empty annotations in both object detection and instance segmentation datasets.
  • Add skip_if_label_file_missing option to optionally exclude samples without label files.
  • Document the behavior change in CHANGELOG.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
src/lightly_train/_data/yolo_object_detection_dataset.py Handle missing label files in __getitem__, add skip flag to args and listing logic.
src/lightly_train/_data/yolo_instance_segmentation_dataset.py Same missing-label handling and skip flag wiring for instance segmentation.
CHANGELOG.md Notes the default behavior change and how to configure skipping.

@guarin
Copy link
Contributor Author

guarin commented Feb 2, 2026

/review

Copy link
Contributor

@IgorSusmelj IgorSusmelj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Nit: I'd mention this in the docs. Common questions I'd have that I'd like to get answered:

  • can I use images without annotations as negatives? E.g. supergradients and other frameworks do not allow that which in some cases is quite limiting. Sometimes I want to explicitly add images as negatives without any labels in them.
  • (similar question): What happens with images that have no labels?

@guarin guarin enabled auto-merge (squash) February 5, 2026 09:41
@guarin guarin merged commit a3a4edb into main Feb 5, 2026
19 checks passed
@guarin guarin deleted the handle-missing-label-files branch February 5, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants