Handle missing detection/segmentation label files#587
Merged
Conversation
Contributor
There was a problem hiding this comment.
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_missingoption 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. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
Author
|
/review |
IgorSusmelj
approved these changes
Feb 3, 2026
Contributor
IgorSusmelj
left a comment
There was a problem hiding this comment.
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?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What has changed and why?
Follow up from #580
How has it been tested?
Did you update CHANGELOG.md?
Did you update the documentation?