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

Added documentation for SAM2 tracker #8820

Merged
merged 4 commits into from
Dec 16, 2024
Merged

Added documentation for SAM2 tracker #8820

merged 4 commits into from
Dec 16, 2024

Conversation

bsekachev
Copy link
Member

@bsekachev bsekachev commented Dec 12, 2024

Motivation and context

How has this been tested?

Checklist

  • I submit my changes into the develop branch
  • I have created a changelog fragment
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • I have linked related issues (see GitHub docs)
  • I have increased versions of npm packages if it is necessary
    (cvat-canvas,
    cvat-core,
    cvat-data and
    cvat-ui)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

Summary by CodeRabbit

  • New Features

    • Introduced documentation for the Segment Anything 2 Tracker, detailing installation and usage for object tracking.
  • Bug Fixes

    • Minor textual modification in the "Social auth configuration" document for clarity.

Copy link
Contributor

coderabbitai bot commented Dec 12, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes include the addition of a new documentation file, segment-anything-2-tracker.md, which provides comprehensive guidance on the Segment Anything 2 Tracker, including installation procedures and operational instructions for enterprise users. Additionally, a minor textual modification was made to the existing document on social account configuration, enhancing clarity without altering the overall content structure or instructions.

Changes

File Path Change Summary
site/content/en/docs/enterprise/segment-anything-2-tracker.md New document added detailing installation and usage of the Segment Anything 2 Tracker.
site/content/en/docs/enterprise/social-accounts-configuration.md Minor textual modification for clarity in the description of social accounts authentication.

Poem

In the garden of code, a new guide takes flight,
The Segment Tracker shines, a beacon of light.
With steps for installation, clear as can be,
Hop along, dear users, and track joyfully!
A tweak here, a word there, to make it just right,
In the world of documentation, all feels so bright! 🐇✨


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

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: 2

🧹 Outside diff range and nitpick comments (3)
site/content/en/docs/enterprise/segment-anything-2-tracker.md (3)

8-15: Consider adding performance expectations

The overview effectively explains the feature, but users would benefit from knowing:

  • Minimum GPU requirements (memory, compute capability)
  • Expected performance differences between GPU and CPU (e.g., average processing time per frame)

73-73: Consider rephrasing for clarity

The current phrase "To do this" could be more specific.

Consider this revision:

-To do this, click the **Menu** button in the annotation view and select the **Run Actions** option:
+To track multiple objects, click the **Menu** button in the annotation view and select the **Run Actions** option:
🧰 Tools
🪛 LanguageTool

[style] ~73-~73: Consider a more expressive alternative.
Context: ...ack multiple objects simultaneously. To do this, click the Menu button in the ...

(DO_ACHIEVE)


95-100: Consider enhancing parameter documentation

The parameters section would benefit from:

  1. Specifying the valid range for target frame (e.g., maximum recommended tracking distance)
  2. Explaining any performance implications of shape conversion
  3. Adding examples of typical usage scenarios for each parameter
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3f44834 and 69d7520.

⛔ Files ignored due to path filters (6)
  • site/content/en/images/sam2_tracker_run_action.png is excluded by !**/*.png
  • site/content/en/images/sam2_tracker_run_action_modal.png is excluded by !**/*.png
  • site/content/en/images/sam2_tracker_run_action_modal_progress.png is excluded by !**/*.png
  • site/content/en/images/sam2_tracker_run_shape_action.png is excluded by !**/*.png
  • site/content/en/images/sam2_tracker_run_shape_action_modal.png is excluded by !**/*.png
  • site/content/en/images/sam2_tracker_run_shape_action_modal_progress.png is excluded by !**/*.png
📒 Files selected for processing (2)
  • site/content/en/docs/enterprise/segment-anything-2-tracker.md (1 hunks)
  • site/content/en/docs/enterprise/social-accounts-configuration.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • site/content/en/docs/enterprise/social-accounts-configuration.md
🧰 Additional context used
🪛 LanguageTool
site/content/en/docs/enterprise/segment-anything-2-tracker.md

[style] ~73-~73: Consider a more expressive alternative.
Context: ...ack multiple objects simultaneously. To do this, click the Menu button in the ...

(DO_ACHIEVE)

🔇 Additional comments (1)
site/content/en/docs/enterprise/segment-anything-2-tracker.md (1)

1-6: LGTM!

The front matter is well-structured with appropriate metadata.

Comment on lines 17 to 46
## How to install

> **Note**: This feature is not available in the community CVAT version.

> **Note**: This feature requires the enhanced actions UI plugin, which is enabled by default.
Usually, no additional steps are necessary on this.

### Docker

You can use existing scripts from the community repository
(`./serverless/deploy_cpu.sh` or `./serverless/deploy_gpu.sh`).
To deploy the feature, simply run:

```sh
./serverless/deploy_gpu.sh "path/to/the/function"
```

### Kubernetes

- You need to deploy the Nuclio function manually.
Note that this function requires a Redis client to store the tracking state.
When running the `nuclio deploy` command, make sure to provide the necessary arguments.
The minimal command is:

```sh
nuctl deploy "path/to/the/function"
--env CVAT_FUNCTIONS_REDIS_HOST="<redis_host>"
--env CVAT_FUNCTIONS_REDIS_PORT="<redis_port>"
--env CVAT_FUNCTIONS_REDIS_PASSWORD="<redis_password>" # if applicable
```
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Installation instructions need more details

Consider enhancing the installation section with:

  1. Redis requirements for Docker deployment (if applicable)
  2. Specific path or location where the function can be found
  3. A troubleshooting section covering common deployment issues

Comment on lines 1 to 100
---
title: 'Segment Anything 2 Tracker'
linkTitle: 'Segment Anything 2 Tracker'
weight: 6
description: 'Accelerating video labeling using SAM2 model'
---

## Overview

Segment Anything 2 is a segmentation model that allows fast and precise selection of any object in videos or images.
For enterprise customers, this model can be installed in their self-hosted solution. To ensure a good experience,
it is strongly recommended to deploy the model using a GPU. Although it is possible to use a CPU-based version,
it generally performs much slower and is suitable only for handling a single parallel request. Unlike a regular
tracking model, the SAM 2 tracker is implemented as an annotation action. This allows it to be applied to existing
objects (polygons and masks) to track them forward for a specified number of frames.

## How to install

> **Note**: This feature is not available in the community CVAT version.

> **Note**: This feature requires the enhanced actions UI plugin, which is enabled by default.
Usually, no additional steps are necessary on this.

### Docker

You can use existing scripts from the community repository
(`./serverless/deploy_cpu.sh` or `./serverless/deploy_gpu.sh`).
To deploy the feature, simply run:

```sh
./serverless/deploy_gpu.sh "path/to/the/function"
```

### Kubernetes

- You need to deploy the Nuclio function manually.
Note that this function requires a Redis client to store the tracking state.
When running the `nuclio deploy` command, make sure to provide the necessary arguments.
The minimal command is:

```sh
nuctl deploy "path/to/the/function"
--env CVAT_FUNCTIONS_REDIS_HOST="<redis_host>"
--env CVAT_FUNCTIONS_REDIS_PORT="<redis_port>"
--env CVAT_FUNCTIONS_REDIS_PASSWORD="<redis_password>" # if applicable
```

## Running tracker on an object

The tracker can be applied to any polygons and masks. To run the tracker on an object, open the object menu and click
"Run annotation action".

<img src="/images/sam2_tracker_run_shape_action.png" style="max-width: 200px; padding: 16px;">

Alternatively, you can use a hotkey: select the object and press **Ctrl + E** (default shortcut).
When the modal opened, in "Select action" list, choose **Segment Anything 2: Tracker**:

<img src="/images/sam2_tracker_run_shape_action_modal.png" style="max-width: 500px; padding: 16px;">

Specify the **target frame** until which you want the object to be tracked,
then click the **Run** button to start tracking. The process begins and may take some time to complete.
The duration depends on the inference device, and the number of frames where the object will be tracked.

<img src="/images/sam2_tracker_run_shape_action_modal_progress.png" style="max-width: 500px; padding: 16px;">

Once the process is complete, the modal window closes. You can review how the object was tracked.
If you notice that the tracked shape deteriorates at some point,
you can adjust the object coordinates and run the tracker again from that frame.

## Running tracker on multiple objects

Instead of tracking each object individually, you can track multiple objects
simultaneously. To do this, click the **Menu** button in the annotation view and select the **Run Actions** option:

<img src="/images/sam2_tracker_run_action.png" style="max-width: 200px; padding: 16px;">

Alternatively, you can use a hotkey: just press **Ctrl + E** (default shortcut) when there are no objects selected.
This opens the actions modal. In this case, the tracker will be applied to all visible objects of suitable types
(polygons and masks). In the action list of the opened model, select **Segment Anything 2: Tracker**:

<img src="/images/sam2_tracker_run_action_modal.png" style="max-width: 500px; padding: 16px;">

Specify the **target frame** until which you want the objects to be tracked,
then click the **Run** button to start tracking. The process begins and may take some time to complete.
The duration depends on the inference device, the number of simultaneously tracked objects,
and the number of frames where the object will be tracked.

<img src="/images/sam2_tracker_run_action_modal_progress.png" style="max-width: 500px; padding: 16px;">

Once the process finishes, you may close the modal and review how the objects were tracked.
If you notice that the tracked shapes deteriorate, you can adjust their
coordinates and run the tracker again from that frame (for a single object or for many objects).


## Tracker parameters

- **Target frame**: Objects will be tracked up to this frame. Must be greater than the current frame
- **Convert polygon shapes to tracks**: When enabled, all visible polygon shapes in the current frame will be converted
to tracks before tracking begins. Use this option if you need tracks as the final output but started with shapes,
produced for example by interactors (e.g. SAM2 or another one).
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider adding essential documentation sections

The documentation would benefit from additional sections:

  1. Model Version & Compatibility
    • Supported SAM2 model versions
    • CVAT version compatibility
  2. Known Limitations
    • Performance limitations
    • Supported object types
    • Edge cases where tracking might fail
🧰 Tools
🪛 LanguageTool

[style] ~73-~73: Consider a more expressive alternative.
Context: ...ack multiple objects simultaneously. To do this, click the Menu button in the ...

(DO_ACHIEVE)

@bsekachev bsekachev merged commit bf6469e into develop Dec 16, 2024
16 checks passed
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.

1 participant