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

<a id="model-zoo-med-sam-2-video-torch"></a>

# med-sam-2-video-torch

Medical segmentation tool that outlines organs and structures in medical videos and 3D scans.

**Details**

- Model name: `med-sam-2-video-torch`
- Model source: [https://github.com/MedicineToken/Medical-SAM2](https://github.com/MedicineToken/Medical-SAM2)
- Model author: Jiayuan Zhu, et al.
- Model license: Apache 2.0
- Model size: 74.46 MB
- Exposes embeddings? no
- Tags: `segment-anything, torch, zero-shot, video, med-SAM, 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
from fiftyone.utils.huggingface import load_from_hub

dataset = load_from_hub("Voxel51/BTCV-CT-as-video-MedSAM2-dataset")[:2]

# Retaining detections from a single frame in the middle
# Note that SAM2 only propagates segmentation masks forward in a video
(
    dataset
    .match_frames(F("frame_number") != 100)
    .set_field("frames.gt_detections", None)
    .save()
)

model = foz.load_zoo_model("med-sam-2-video-torch")

# Segment inside boxes and propagate to all frames
dataset.apply_model(
    model,
    label_field="pred_segmentations",
    prompt_field="frames.gt_detections",
)

session = fo.launch_app(dataset)
```
