SAM 2 Segmentation & Tracking
Segment Anything Model 2 (SAM 2) allows you to automatically create labels around distinct features in all supported file formats.
See the video, or use the step-by-step tutorial below to learn how to use SAM 2 effectively.
SAM 2 Segmentation
Availability
SAM 2 supports labeling the following Ontology shapes.
Ontology Shape | Supported? |
---|---|
Polygon | ✅ |
Bounding box | ✅ |
Bitmask | ✅ |
Keypoint | ❌ |
Polyline | ❌ |
Skeleton | ❌ |
SAM 2 supports labeling the following modalities.
Modality | Supported |
---|---|
Single Image | ✅ |
Image Group | ✅ |
Image Sequence | ✅ |
Video | ✅ |
Audio | ❌ |
Text / HTML | ❌ |
Document | ❌ |
New Instances
Use the Shift + A keyboard shortcut to toggle SAM mode. Enabling SAM mode automatically activates SAM 2 whenever the class is selected, so there’s no need to click the wand icon separately.
-
Click the wand icon on Ontology class you want to label with.
-
Click, or click-and-drag the cursor across the part of the image you want to label. The SAM popup appears.
- Left-click parts of the image to include them in the label.
- Right-click parts of the selection to exclude them from the label.
- Click Save or press ENTER
Existing Instances
Videos and image sequences can show a single object instance in multiple frames.
- Navigate to the frame you want to create the label.
- Click the Toggle auto-annotation button or use the SHIFT + A keyboard shortcut.
SAM mode remains active when switching to a different annotation class. Deactivate SAM 2 by clicking the Toggle auto-annotation button, or using the SHIFT + A keyboard shortcut again.
- Click, or click-and-drag the cursor across the part of the image you want to label. The SAM popup appears.
- Left-click parts of the image to include them in the label.
- Right-click parts of the selection to exclude them from the label.
- Click Save or press ENTER
SAM 2 Tracking
SAM 2 supports tracking objects across multiple frames.
SAM 2 tracking is computationally intensive and performance might be slower than other labeling actions.
Availability
The following table shows the Ontology shapes for which SAM 2 tracking can be used.
Ontology shape | SAM 2 Video Tracking |
---|---|
Bounding box | ✅ |
Rotatable bounding box | ✅ |
Polygon | ✅ |
Polyline | ❌ |
Primitive | ❌ |
Keypoint | ❌ |
Bitmask | ✅ |
The following table shows the modalities that support SAM 2 tracking.
Modalities | SAM 2 Video Tracking |
---|---|
Images | ❌ |
Videos | ✅ |
Image Groups | ✅ |
Image Sequences | ✅ |
DICOM | ✅ |
Audio | ❌ |
Text / HTML | ❌ |
Documents | ❌ |
Track While Creating Labels
Before you begin, set your tracking range in the Editor Settings. By default, object tracking is configured to run for 30 frames, meaning SAM 2 tracking tracks the object across 30 consecutive frames.
-
Click the wand icon next to the class you want to label, or press Shift + A to toggle SAM mode.
-
Click on the instance you want to label. Adjust your label until the correct region is selected by SAM 2 if needed.
-
Specify the number of frames you want to track the instance across.
-
Click Run tracking or press Shift + T to start the SAM 2 tracking algorithm.
-
Click Save when tracking completes to save the generated labels.
Track Existing Instances
Method 1:
-
Click Automated labeling.
-
Expand the Tracking and interpolation section.
-
Select the instances you want to track.
-
Make sure the Tracking method is selected.
-
Set the tracking annotation interval. This defines how many consecutive frames an instance can be missing before the tracking algorithm stops.
-
Specify the frame range you want to track the selected instances across.
-
Click Run tracking to begin the process.
Method 2:
Before you begin, set your default tracking range in the Editor Settings. By default, object tracking is configured to run for 30 frames, meaning SAM 2 tracking tracks the object across 30 consecutive frames.
-
Right-click the instance label you want to start tracking.
-
Click Track object to run SAM 2 tracking or use the keyboard shortcut Shift + T to run SAM 2 tracking for 30 consecutive frames.
Tracking Multiple Objects
To track multiple objects of any shape:
-
Click one of the objects you want to track.
-
Hold Shift on your keyboard and select all the other objects you want to track.
-
Right-click on one of the selected objects and click Track X objects, where
X
is the number of objects selected.
Settings
The Object tracking section of the editor settings allows you to adjust the following.
Change Tracking Range
The range SAM 2 object tracking runs can be adjusted in the Object tracking section of the editor settings. The default tracking range is set to 30 frames. This range includes the frame that SAM 2 tracking starts on.
Advanced Tracking
This toggle lets you choose between a faster, simpler tracking algorithm or a slower, more advanced one with higher accuracy. The advanced algorithm is enabled by default.