-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ultralytics yolo support for tracks #8883
Conversation
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe pull request introduces enhancements to the CVAT dataset manager, focusing on expanding support for YOLO formats and improving annotation transformations. The changes include adding new YOLO-related formats (Ultralytics detection, segmentation, oriented boxes, and pose), implementing new transformation classes for mask and annotation conversions, and updating the necessary test and configuration files to support these new formats. Changes
Sequence DiagramsequenceDiagram
participant DM as Dataset Manager
participant Converter as Annotation Converter
participant Exporter as YOLO Exporter
DM->>Converter: Transform annotations
Converter-->>DM: Converted annotations
DM->>Exporter: Export dataset
Exporter-->>DM: Exported YOLO format
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
cvat/apps/dataset_manager/formats/transformations.py (2)
Line range hint
104-119
: Double-check ellipse drawing assumptions inEllipsesToMasks
.The ellipse conversion logic looks straightforward. Consider verifying:
- Rotation calculations are consistent with the annotation specification.
- The image boundary is respected for large ellipses or those near the border.
- The ellipse’s integer rounding (using
round
) doesn’t skip edge pixels for partially included boundaries.
138-145
: Ensure no conflicts when overwriting thekeyframe
attribute.By setting
keyframe=True
for every annotation that has atrack_id
, you override any existingkeyframe
attributes. If the dataset already has akeyframe
set to another value, it will be lost. Consider preserving the originalkeyframe
if it exists.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
cvat/apps/dataset_manager/bindings.py
(1 hunks)cvat/apps/dataset_manager/formats/transformations.py
(4 hunks)cvat/apps/dataset_manager/formats/yolo.py
(4 hunks)cvat/apps/dataset_manager/tests/assets/annotations.json
(1 hunks)cvat/apps/dataset_manager/tests/test_formats.py
(1 hunks)cvat/apps/dataset_manager/tests/test_rest_api_formats.py
(1 hunks)cvat/requirements/base.in
(1 hunks)cvat/requirements/base.txt
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- cvat/apps/dataset_manager/tests/test_rest_api_formats.py
🔇 Additional comments (13)
cvat/apps/dataset_manager/formats/transformations.py (2)
Line range hint 40-103
: Evaluate clarity and potential edge cases in MaskConverter
.
Overall, the MaskConverter
class is logically cohesive and uses COCO RLE encoding properly. However, ensure that:
- The bounding box offsets (
left
,top
,right
,bottom
) don’t exceed image boundaries for edge-case shapes. - Large masks are handled efficiently to avoid unnecessary memory overhead.
- Potential corner cases (e.g., immediate zero-width or zero-height masks) are tested.
Line range hint 120-135
: Confirm conversion skip logic in MaskToPolygonTransformation
.
The transformation is only applied if conv_mask_to_poly
is true (default). Make sure that:
dataset.transform('masks_to_polygons')
respects the segmentation definitions in all annotation types.- There's a test or fallback for shapes that are not strictly masks, to avoid potential runtime issues.
cvat/apps/dataset_manager/formats/yolo.py (7)
7-7
: Importing Optional
and Callable
is helpful for clarity.
Good job including type hints for readability and maintainability.
26-26
: SetKeyframeForEveryTrackShape import aligns transformations across modules.
Including this transformation in YOLO logic ensures consistent track annotation post-import.
29-37
: New parameter write_track_id
in _export_common
enhances track ID support.
Providing a boolean toggle for track ID export is an elegant way to maintain backward compatibility and add new functionality.
40-40
: Passing write_track_id
to dataset.export
is correct.
This effectively links the new parameter to your dataset logic for YOLO exports.
52-57
: Type hints for _import_common
improve function clarity.
The typed parameters facilitate better tooling support (IDE hints, static analysis) and reduce confusion about expected argument types.
82-82
: Applying SetKeyframeForEveryTrackShape
after import.
Ensuring each imported annotation with a track_id
has keyframe=True
is consistent with the new track-based YOLO workflows, but watch for potential collisions with existing keyframe
states as noted in the transformations file.
98-101
: Dedicated exporter for Ultralytics YOLO Detection Track
.
Introducing _export_yolo_ultralytics_detection
with write_track_id=True
is consistent with your track annotation changes. This isolates new format logic, avoiding confusion with existing YOLO exporters.
cvat/apps/dataset_manager/tests/test_formats.py (1)
298-298
: New format 'Ultralytics YOLO Detection Track 1.0'
aligns with track-based enhancements.
Explicitly enumerating the new format in the test suite validates the workflow for track-based YOLO detection. Verify that test coverage includes exporting and importing actual track data.
cvat/apps/dataset_manager/bindings.py (1)
2178-2182
: Looks good extending track formats to Ultralytics YOLO variants.
These entries are consistent with the existing approach for specifying track-compatible formats. No issues detected.
cvat/requirements/base.txt (1)
59-59
: Upgrade Datumaro revision with caution.
Upgrading to the new commit may introduce breaking changes. Please verify that all dependent features and tests remain stable.
cvat/apps/dataset_manager/tests/assets/annotations.json (1)
1011-1057
: New test entry for "Ultralytics YOLO Detection Track 1.0" increases coverage.
The example includes both shapes and tracks, showcasing outside and keyframe flags, which is helpful for validating correct track extraction. This addition aligns well with the new YOLO track features.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #8883 +/- ##
===========================================
- Coverage 73.93% 73.93% -0.01%
===========================================
Files 411 411
Lines 44223 44237 +14
Branches 3993 3993
===========================================
+ Hits 32698 32705 +7
- Misses 11525 11532 +7
|
# Conflicts: # cvat/apps/dataset_manager/formats/yolo.py # cvat/requirements/base.in # cvat/requirements/base.txt
@@ -67,6 +79,7 @@ def _import_common( | |||
detect_dataset(temp_dir, format_name=format_name, importer=dm_env.importers.get(format_name)) | |||
dataset = Dataset.import_from(temp_dir, format_name, | |||
env=dm_env, image_info=image_info, **(import_kwargs or {})) | |||
dataset = dataset.transform(SetKeyframeForEveryTrackShape) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if an annotation's attributes does not contain keyframe
, the execution goes here: https://github.com/cvat-ai/cvat/blob/develop/cvat/apps/dataset_manager/bindings.py#L2260 and does not go here: https://github.com/cvat-ai/cvat/blob/develop/cvat/apps/dataset_manager/bindings.py#L2300
and therefore track is not recognised as track and _validate_track_shapes
is not executed for it
Co-authored-by: Maxim Zhiltsov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update changelog, it's a noticeable change.
done |
Quality Gate passedIssues Measures |
Motivation and context
Can now import Ultralytics Yolo formats with track_id
Can now export Ultralytics Yolo Detection with track_id
depends on cvat-ai/datumaro#70
How has this been tested?
Checklist
develop
branch(cvat-canvas,
cvat-core,
cvat-data and
cvat-ui)
License
Feel free to contact the maintainers if that's a concern.
Summary by CodeRabbit
Release Notes
New Features
MaskConverter
,EllipsesToMasks
,MaskToPolygonTransformation
, andSetKeyframeForEveryTrackShape
.Bug Fixes
Tests
Chores
datumaro
package to a newer version in requirements files.