-
Notifications
You must be signed in to change notification settings - Fork 583
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
Add track ids if present for ultralytics models #4569
Conversation
WalkthroughThis update introduces functions to extract track IDs from Ultralytics results and modifies existing functions to include track ID processing. The changes enhance the ability to keep track of object identities across frames, crucial for tasks like object tracking in video analysis. Changes
Sequence Diagram(s)sequenceDiagram
participant Ultralytics as Ultralytics Model
participant FOUtils as fiftyone.utils.ultralytics
participant Result as Ultralytics Result
Ultralytics->>Result: Generate Results
Result->>FOUtils: Pass Results
FOUtils->>+FOUtils: _extract_track_ids(result)
FOUtils->>-FOUtils: Return Track IDs
FOUtils->>Result: Process Results with Track IDs
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 as PR comments)
Additionally, you can add CodeRabbit Configration 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: 0
Outside diff range, codebase verification and nitpick comments (1)
fiftyone/utils/ultralytics.py (1)
56-62
: Add a comment explaining the function logic.The function
_extract_track_ids
handles the presence and absence of track IDs. Adding a comment will improve code readability.def _extract_track_ids(result): """Get ultralytics track ids if present, else use Nones""" # Extract track IDs if they are present; otherwise, return a list of None return ( result.boxes.id.detach().cpu().numpy().astype(int) if result.boxes.is_track else [None] * len(result.boxes.conf.size(0)) )
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- fiftyone/utils/ultralytics.py (10 hunks)
Additional comments not posted (4)
fiftyone/utils/ultralytics.py (4)
Line range hint
95-110
:
LGTM! The changes correctly incorporate track IDs into detections.The track IDs are correctly added to the
fol.Detection
objects.
Line range hint
149-180
:
LGTM! The changes correctly incorporate track IDs into instances.The track IDs are correctly added to the
fol.Detection
objects within instance segmentations.
Line range hint
276-305
:
LGTM! The changes correctly incorporate track IDs into polylines.The track IDs are correctly added to the
fol.Polyline
objects.
Line range hint
346-360
:
LGTM! The changes correctly incorporate track IDs into keypoints.The track IDs are correctly added to the
fol.Keypoint
objects.
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.
LGTM, thanks! 💪
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #4569 +/- ##
============================================
- Coverage 99.27% 28.77% -70.50%
============================================
Files 47 857 +810
Lines 16212 106376 +90164
Branches 0 1374 +1374
============================================
+ Hits 16095 30614 +14519
- Misses 117 75762 +75645
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
What changes are proposed in this pull request?
If running
track
method fromultralytics.YOLO
model, then track ids will be available video files.If track ids are present, we add then to
fiftyone.Detection(index=track_id)
and other labels.How is this patch tested? If it is not, please explain why.
Works with detection and pose estimation models for the ultralytics integration.
Release Notes
Is this a user-facing change that should be mentioned in the release notes?
notes for FiftyOne users.
When running ultralytics models on video files, track ids will be internally added to label fields with a instance index.
What areas of FiftyOne does this PR affect?
fiftyone
Python library changesSummary by CodeRabbit