Skip to content
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

DeepSort tracking enhancements #4372

Merged
merged 2 commits into from
May 8, 2024
Merged

Conversation

brimoor
Copy link
Contributor

@brimoor brimoor commented May 8, 2024

Change log

  • add validation based on media/field types
  • handle frames where input detections field is null/missing
  • use select_fields() to optimize I/O
  • add skip_failures=True/False flag
  • use FFmpegVideoReader for more robust/idiomatic video processing
  • add track_sample() method for running tracking on individual samples

Example usage

import fiftyone as fo
import fiftyone.zoo as foz
from fiftyone.utils.tracking import DeepSort

dataset = foz.load_zoo_dataset("quickstart-video")

DeepSort.track(dataset, "frames.detections")

session = fo.launch_app(dataset)

Summary by CodeRabbit

  • Refactor
    • Enhanced class and method definitions in the tracking module for improved functionality and error handling.
  • New Features
    • Added a new method for tracking individual samples within collections, enhancing user flexibility and control.

@brimoor brimoor added the enhancement Code enhancement label May 8, 2024
@brimoor brimoor requested a review from jacobmarks May 8, 2024 17:20
Copy link
Contributor

coderabbitai bot commented May 8, 2024

Walkthrough

The recent updates to the DeepSort class in the fiftyone library focus on refining the tracking functionality. Key changes include renaming parameters for clarity, enhancing flexibility with new options, and expanding functionality with additional methods. These modifications aim to improve user experience and adaptability of the tracking process in video and sample collections.

Changes

File Path Change Summary
fiftyone/utils/tracking/deepsort.py - Added and altered imports
- Modified DeepSort class and track method
- Added track_sample method

🐇✨
In the code where trackers play,
A rabbit hopped by, tweaking away.
With a flip and a skip, parameters align,
Now tracking's more robust, oh so fine!
Celebrate the code, hip hip hooray! 🎉
🐇✨


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@brimoor brimoor changed the title Handle errors, validation, add support for tracking on individual sam… DeepSort tracking enhancements May 8, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Out of diff range and nitpick comments (1)
fiftyone/utils/tracking/deepsort.py (1)

25-25: Class now explicitly inherits from object, which is good practice in Python 2 but redundant in Python 3. Consider removing if Python 3 is the target.

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 8263d7c and 75c9f77.
Files selected for processing (1)
  • fiftyone/utils/tracking/deepsort.py (2 hunks)
Additional comments not posted (6)
fiftyone/utils/tracking/deepsort.py (6)

10-10: Ensure the new import eta.core.video as etav is used appropriately in the file.


14-14: Ensure the new import fiftyone.core.validation as fov is used appropriately in the file.


28-60: Review the changes in the track method:

  • Parameter dataset changed to sample_collection to better reflect its functionality.
  • Added parameter skip_failures=True to allow users to choose whether to ignore errors during tracking.
  • Changed default value of parameter progress from True to False to possibly streamline output and reduce clutter during processing.

66-69: Validation functions are used to ensure the video collection and label fields are appropriate before tracking. This is a good practice to prevent runtime errors.


71-86: The loop iterates over samples and applies tracking. Errors are handled based on the skip_failures flag, and warnings are logged appropriately. This is a robust error handling strategy.


Line range hint 89-164: Review the new track_sample method:

  • Performs object tracking on individual video samples.
  • Uses FFmpegVideoReader for reading video frames, which is known for its robustness.
  • Properly handles bounding boxes and tracking, storing results in the specified output field.
  • Conditionally stores confidence if keep_confidence is True.
    This method enhances the granularity of tracking operations and is well-implemented.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 75c9f77 and 303c416.
Files selected for processing (1)
  • fiftyone/utils/tracking/deepsort.py (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • fiftyone/utils/tracking/deepsort.py

Copy link
Contributor

@jacobmarks jacobmarks left a comment

Choose a reason for hiding this comment

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

Works for me, and looks good. Solid enhancements! I'm seeing better performance with the FFmpegVideoReader than with cv2, and the frame field handling is cool, didn't realize we had that!

@jacobmarks jacobmarks merged commit 1e75753 into release/v0.24.0 May 8, 2024
9 of 10 checks passed
@jacobmarks jacobmarks deleted the deepsort-updates branch May 8, 2024 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Code enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants