<!-- # hard line break macro for HTML -->

<a id="model-zoo-segment-anything-2-hiera-base-plus-video-torch"></a>

# segment-anything-2-hiera-base-plus-video-torch

Video segmentation model that tracks and outlines objects throughout clips for editing and analysis.

**Details**

- Model name: `segment-anything-2-hiera-base-plus-video-torch`
- Model source: [https://ai.meta.com/sam2/](https://ai.meta.com/sam2/)
- Model author: Nikhila Ravi, et al.
- Model license: Apache 2.0, BSD 3-Clause
- Model size: 308.51 MB
- Exposes embeddings? no
- Tags: `segment-anything, torch, zero-shot, video, transformer, official`

**Requirements**

- Packages: `torch, torchvision, sam2`
- CPU support
  - yes
- GPU support
  - yes

**Example usage**

```python
import fiftyone as fo
import fiftyone.zoo as foz
from fiftyone import ViewField as F

dataset = foz.load_zoo_dataset("quickstart-video", max_samples=2)

# Only retain detections in the first frame
(
    dataset
    .match_frames(F("frame_number") > 1)
    .set_field("frames.detections", None)
    .save()
)

model = foz.load_zoo_model("segment-anything-2-hiera-base-plus-video-torch")

# Segment inside boxes and propagate to all frames
dataset.apply_model(
    model,
    label_field="segmentations",
    prompt_field="frames.detections",  # can contain Detections or Keypoints
)

session = fo.launch_app(dataset)
```
