Skip to content

Add coco object detection dataset#677

Merged
simonschoelly merged 18 commits intomainfrom
simon-add-coco-object-detection-dataset
Apr 7, 2026
Merged

Add coco object detection dataset#677
simonschoelly merged 18 commits intomainfrom
simon-add-coco-object-detection-dataset

Conversation

@simonschoelly
Copy link
Copy Markdown
Contributor

@simonschoelly simonschoelly commented Mar 30, 2026

What has changed and why?

  • Added COCO format input for object detection
  • Added some tests for get_class_id_to_internal_class_id_mapping because that method was not covered anymore after this PR.
  • Had to disable the test_file_locking_concurrent_increments test on Python 3.8 because it kept failing even after restarting the tests.

How has it been tested?

  • Wrote some tests to cover the new dataset
  • Wrote a test that runs the train loop with a COCO dataset.

Did you update CHANGELOG.md?

  • Yes
  • Not needed (internal change)

Did you update the documentation?

Coming in a follow up PR

@simonschoelly simonschoelly force-pushed the simon-add-coco-object-detection-dataset branch 8 times, most recently from cbdec4f to 670207e Compare March 31, 2026 16:09
@simonschoelly simonschoelly marked this pull request as ready for review March 31, 2026 18:43
Copilot AI review requested due to automatic review settings March 31, 2026 18:43
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@simonschoelly
Copy link
Copy Markdown
Contributor Author

/review

Copy link
Copy Markdown
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

This PR adds COCO-format dataset support for object detection and refactors YOLO object detection to reuse a new shared ObjectDetectionDataset implementation, with accompanying test updates and a changelog entry.

Changes:

  • Add COCOObjectDetectionDataArgs/COCOObjectDetectionDatasetArgs and support selecting COCO vs YOLO via a discriminated union in the train task config.
  • Introduce a generic ObjectDetectionDataset and switch YOLO object detection dataset args to use it.
  • Add/adjust tests for COCO datasets, label helper mapping, and object detection training (YOLO + COCO); skip a flaky file-locking test on Python 3.8.

Reviewed changes

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

Show a summary per file
File Description
tests/helpers.py Adds a helper to generate minimal COCO-format object detection datasets for tests.
tests/_data/test_yolo_object_detection_dataset.py Updates YOLO tests to validate list_image_info() output format.
tests/_data/test_object_detection_dataset.py Adds coverage for the new shared ObjectDetectionDataset behavior.
tests/_data/test_label_helpers.py Adds tests for get_class_id_to_internal_class_id_mapping.
tests/_data/test_coco_object_detection_dataset.py Adds tests for COCO dataset args list_image_info() normalization and class remapping.
tests/_commands/test_train_task.py Splits YOLO OD training test and adds an end-to-end COCO OD training test.
tests/_commands/test_common_helpers.py Skips a flaky multiprocessing file-locking test on Python 3.8.
src/lightly_train/_data/yolo_object_detection_dataset.py Removes the dedicated YOLO dataset class and routes YOLO args to the shared dataset.
src/lightly_train/_data/object_detection_dataset.py Introduces shared dataset implementation for object detection samples and transforms.
src/lightly_train/_data/coco_object_detection_dataset.py Adds COCO dataset args + parsing logic for COCO JSON annotations.
src/lightly_train/_commands/train_task.py Enables discriminated-union parsing for object detection data config (YOLO vs COCO).
CHANGELOG.md Documents COCO object detection dataset format support.

Comment thread tests/helpers.py Outdated
Comment thread src/lightly_train/_data/object_detection_dataset.py
Comment thread src/lightly_train/_commands/train_task.py
Comment thread src/lightly_train/_data/coco_object_detection_dataset.py Outdated
Comment thread tests/_data/test_object_detection_dataset.py Outdated
Comment thread src/lightly_train/_commands/train_task.py Outdated
Comment thread tests/_commands/test_train_task.py Outdated
Comment thread CHANGELOG.md
Comment thread src/lightly_train/_data/yolo_object_detection_dataset.py
@simonschoelly simonschoelly force-pushed the simon-add-coco-object-detection-dataset branch from 61a6cd8 to 64acb96 Compare April 2, 2026 01:43
Comment thread src/lightly_train/_data/coco_object_detection_dataset.py Outdated
@simonschoelly simonschoelly force-pushed the simon-add-coco-object-detection-dataset branch from 64acb96 to c8648cb Compare April 2, 2026 12:23
@simonschoelly simonschoelly changed the title Simon add coco object detection dataset Add coco object detection dataset Apr 2, 2026
Copy link
Copy Markdown
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

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Comment thread tests/helpers.py Outdated
Comment thread tests/helpers.py
Comment thread tests/_data/test_coco_object_detection_dataset.py Outdated
Comment thread src/lightly_train/_data/coco_object_detection_dataset.py
@simonschoelly simonschoelly enabled auto-merge (squash) April 2, 2026 14:27
@simonschoelly simonschoelly force-pushed the simon-add-coco-object-detection-dataset branch from 552f4ac to d74e36b Compare April 7, 2026 09:20
@simonschoelly simonschoelly merged commit 5f3170e into main Apr 7, 2026
16 checks passed
@simonschoelly simonschoelly deleted the simon-add-coco-object-detection-dataset branch April 7, 2026 09:36
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.

4 participants