Views
No views yet
📖 Learn more: Check out the accompanying blog post explaining the SAM3 architecture and this implementation.
1# Clone the repository
2git clone https://github.com/Deekshith-Dade/mlx_sam3.git
3cd mlx-sam3
4
5# Install with uv (recommended)
6uv sync
7
8# Or with pip
9pip install -e .1from PIL import Image
2from sam3 import build_sam3_image_model
3from sam3.model.sam3_image_processor import Sam3Processor
4
5# Load model (auto-downloads weights on first run)
6model = build_sam3_image_model()
7processor = Sam3Processor(model, confidence_threshold=0.5)
8
9# Load and process an image
10image = Image.open("your_image.jpg")
11state = processor.set_image(image)
12
13# Segment with text prompt
14state = processor.set_text_prompt("person", state)
15
16# Access results
17masks = state["masks"] # Binary segmentation masks
18boxes = state["boxes"] # Bounding boxes [x0, y0, x1, y1]
19scores = state["scores"] # Confidence scores
20
21print(f"Found {len(scores)} objects")cd app && ./run.sh| Requirement | Version | Notes |
|---|---|---|
| macOS | 13.0+ | Apple Silicon required (M1/M2/M3/M4) |
| Python | 3.13+ | Required for MLX compatibility |
| Node.js | 18+ | For the web interface (optional) |
⚠️ Apple Silicon Only: This implementation uses MLX, which is optimized exclusively for Apple Silicon.
1@misc{mlx-sam3,
2 author = {Deekshith Dade},
3 title = {MLX SAM3: Native Apple Silicon Implementation},
4 year = {2024},
5 url = {https://github.com/Deekshith-Dade/mlx_sam3}
6}