File size: 2,833 Bytes
14114e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
title: SAM3 Video Segmentation and Tracking with Text Prompt
emoji: 🎬
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.9.1
app_file: app_loader.py
pinned: false
---

# 🎬 SAM3 Video Segmentation and Tracking with Text Prompt

A HuggingFace Spaces app that automatically segments and tracks objects in videos using text prompts.

**A HSMU Project. All rights reserved.**

## ✨ Key Features

- **Text-driven segmentation**: Describe the target object in natural language
- **Multiple objects**: Segment several objects at once by separating them with commas
- **Temporal consistency**: Tracks objects across frames for stable masks
- **Distinct colors**: Assigns unique colors for each object
- **Live progress**: Watch processing updates in real time
- **High-quality output**: Produces MP4 encoded with H.264 for broad compatibility

## πŸš€ How to Use

1. **Upload a video**: Provide an MP4 file
2. **Enter prompts**: Type the objects to segment
   - Single object: `bed`, `person`, `car`, `dog`, etc.
   - Multiple objects: `bed, pillow, person` (comma-separated)
3. **Run**: Click the "πŸš€ Run Segmentation" button
4. **Review results**: Preview and download the segmented video

## πŸ“‹ Examples

### Single-object segmentation
```
Prompt: bed
Result: Only the bed is segmented and highlighted
```

### Multi-object segmentation
```
Prompt: bed, pillow, person
Result: Bed, pillow, and person are segmented with unique colors
```

## πŸ› οΈ Tech Stack

- **Model**: SAM3 (Segment Anything Model 3)
- **Framework**: Gradio
- **Video processing**: OpenCV, FFmpeg
- **Deep learning**: PyTorch

## πŸ“Š Performance & Limitations

- **Processing time**: Scales with video length and resolution
- **Multiple objects**: More objects increase runtime (roughly N objects β‰ˆ NΓ— time)
- **GPU requirement**: GPU needed to run SAM3 efficiently
- **Memory**: High-resolution videos require more memory

## πŸ”§ Run Locally

```bash
# Clone the space
git clone https://huggingface.co/spaces/bellmake/SAM3-video-segmentation-tracking
cd SAM3-video-segmentation-tracking

# Install dependencies
pip install -r requirements.txt

# Start the app
python app.py
```

## πŸ“ Project Structure

```
.
β”œβ”€β”€ app.py                          # Main Gradio app
β”œβ”€β”€ requirements.txt                # Python dependencies
β”œβ”€β”€ packages.txt                    # System packages (FFmpeg)
β”œβ”€β”€ bedroom.mp4                     # Sample video
β”œβ”€β”€ example_sam3_project_local/     # Local SAM3 project
└── README.md                       # This file
```

## 🀝 Contributing

Issues and pull requests are welcome!


## πŸ“„ License

Unauthorized use of this code is prohibited.\n
For inquiries regarding permissions, please send email to : bellmake@naver.com

---

**Powered by SAM3 & HuggingFace Spaces**