SAM2 Video

Track and segment any object through video with Meta's SAM2.

circle-check
circle-info

All examples in this guide can be run on GPU servers rented through CLORE.AI Marketplacearrow-up-right marketplace.

Renting on CLORE.AI

  1. Filter by GPU type, VRAM, and price

  2. Choose On-Demand (fixed rate) or Spot (bid price)

  3. Configure your order:

    • Select Docker image

    • Set ports (TCP for SSH, HTTP for web UIs)

    • Add environment variables if needed

    • Enter startup command

  4. Select payment: CLORE, BTC, or USDT/USDC

  5. Create order and wait for deployment

Access Your Server

  • Find connection details in My Orders

  • Web interfaces: Use the HTTP port URL

  • SSH: ssh -p <port> root@<proxy-address>

What is SAM2?

SAM2 (Segment Anything Model 2) by Meta AI enables:

  • Real-time video object segmentation

  • Click-to-track any object

  • Consistent tracking through occlusions

  • Memory-efficient video processing

Resources

Component
Minimum
Recommended
Optimal

GPU

RTX 3060 12GB

RTX 4080 16GB

RTX 4090 24GB

VRAM

8GB

16GB

24GB

CPU

4 cores

8 cores

16 cores

RAM

16GB

32GB

64GB

Storage

30GB SSD

50GB NVMe

100GB NVMe

Internet

100 Mbps

500 Mbps

1 Gbps

Quick Deploy on CLORE.AI

Docker Image:

Ports:

Command:

Accessing Your Service

After deployment, find your http_pub URL in My Orders:

  1. Go to My Orders page

  2. Click on your order

  3. Find the http_pub URL (e.g., abc123.clorecloud.net)

Use https://YOUR_HTTP_PUB_URL instead of localhost in examples below.

Installation

What You Can Create

Video Editing

  • Remove objects from videos

  • Replace backgrounds seamlessly

  • Create video masks for compositing

Sports Analysis

  • Track players through games

  • Analyze movement patterns

  • Generate highlight reels

Medical Imaging

  • Segment organs in CT/MRI videos

  • Track cell movement in microscopy

  • Measure growth over time

Surveillance & Security

  • Track objects across cameras

  • Count people/vehicles

  • Anomaly detection

Creative Projects

  • Rotoscoping for VFX

  • Interactive video installations

  • AR/VR content creation

Basic Usage

Image Segmentation

Video Object Tracking

Multi-Object Tracking

Box Prompt Segmentation

Gradio Interface

Export Masks as Video

Performance

Task
Resolution
GPU
Speed

Image segmentation

1024x1024

RTX 3090

50ms

Image segmentation

1024x1024

RTX 4090

30ms

Video (per frame)

720p

RTX 4090

45ms

Video (per frame)

1080p

A100

35ms

Model Variants

Model
Parameters
VRAM
Speed
Quality

sam2_hiera_tiny

38M

4GB

Fastest

Good

sam2_hiera_small

46M

5GB

Fast

Better

sam2_hiera_base

80M

8GB

Medium

Great

sam2_hiera_large

224M

12GB

Slower

Best

Common Problems & Solutions

Out of Memory

Problem: CUDA out of memory on long videos

Solutions:

Tracking Lost

Problem: Object tracking fails mid-video

Solutions:

  • Add correction points when tracking drifts

  • Use box prompts for better initial segmentation

  • Choose clearer initial frames

Slow Processing

Problem: Video processing is too slow

Solutions:

  • Use smaller model variant (tiny/small)

  • Reduce video resolution

  • Enable half-precision (fp16)

  • Process on A100 GPU

Poor Mask Quality

Problem: Segmentation edges are rough

Solutions:

  • Use larger model (large instead of tiny)

  • Add more point prompts

  • Combine point and box prompts

Troubleshooting

Segmentation inaccurate

  • Click more precisely on target object

  • Add multiple positive/negative points

  • Use box prompt for large objects

Video memory error

  • Process fewer frames at once

  • Reduce video resolution

  • Use streaming mode for long videos

Tracking lost

  • Add more prompts when object changes

  • Use memory bank feature

  • Check object isn't occluded

Slow processing

  • SAM2 is compute-heavy

  • Use A100 for long videos

  • Consider frame skipping

Cost Estimate

Typical CLORE.AI marketplace rates (as of 2024):

GPU
Hourly Rate
Daily Rate
4-Hour Session

RTX 3060

~$0.03

~$0.70

~$0.12

RTX 3090

~$0.06

~$1.50

~$0.25

RTX 4090

~$0.10

~$2.30

~$0.40

A100 40GB

~$0.17

~$4.00

~$0.70

A100 80GB

~$0.25

~$6.00

~$1.00

Prices vary by provider and demand. Check CLORE.AI Marketplacearrow-up-right for current rates.

Save money:

  • Use Spot market for flexible workloads (often 30-50% cheaper)

  • Pay with CLORE tokens

  • Compare prices across different providers

Next Steps

Last updated

Was this helpful?