Instructions to use mlx-community/EdgeTAM-fp16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use mlx-community/EdgeTAM-fp16 with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] huggingface-cli download --local-dir EdgeTAM-fp16 mlx-community/EdgeTAM-fp16
- sam2
How to use mlx-community/EdgeTAM-fp16 with sam2:
# Use SAM2 with images import torch from sam2.sam2_image_predictor import SAM2ImagePredictor predictor = SAM2ImagePredictor.from_pretrained(mlx-community/EdgeTAM-fp16) with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16): predictor.set_image(<your_image>) masks, _, _ = predictor.predict(<input_prompts>)# Use SAM2 with videos import torch from sam2.sam2_video_predictor import SAM2VideoPredictor predictor = SAM2VideoPredictor.from_pretrained(mlx-community/EdgeTAM-fp16) with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16): state = predictor.init_state(<your_video>) # add new prompts and instantly get the output on the same frame frame_idx, object_ids, masks = predictor.add_new_points(state, <your_prompts>): # propagate the prompts to get masklets throughout the video for frame_idx, object_ids, masks in predictor.propagate_in_video(state): ... - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: mlx
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
license_link: https://github.com/facebookresearch/EdgeTAM/blob/main/LICENSE
|
| 5 |
+
base_model: facebookresearch/EdgeTAM
|
| 6 |
+
pipeline_tag: image-segmentation
|
| 7 |
+
tags:
|
| 8 |
+
- mlx
|
| 9 |
+
- segmentation
|
| 10 |
+
- promptable-segmentation
|
| 11 |
+
- sam2
|
| 12 |
+
- edgetam
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# mlx-community/EdgeTAM-fp16
|
| 16 |
+
|
| 17 |
+
[EdgeTAM](https://github.com/facebookresearch/EdgeTAM) — on-device SAM 2 for promptable segmentation —
|
| 18 |
+
converted to **Apple MLX** (`-fp16`) for the [`mlx-edgetam-swift`](https://github.com/xocialize/mlx-edgetam-swift)
|
| 19 |
+
Swift package (MLXEngine `promptSegment` ModelPackage). **Image-mode** (point/box → mask); 22× faster
|
| 20 |
+
than SAM 2, 16 FPS on iPhone 15 Pro Max.
|
| 21 |
+
|
| 22 |
+
From-scratch MLX-Swift architecture port: RepViT-M1 image encoder + FPN + SAM prompt encoder + two-way
|
| 23 |
+
mask decoder. Parity-locked vs the PyTorch oracle on the CPU stream (image_embed 9.7e-6, mask logits
|
| 24 |
+
8.9e-5). This `-fp16` build is functionally identical (end-to-end mask **IoU 0.99** vs PyTorch; the
|
| 25 |
+
thresholded mask absorbs fp16 weight-rounding).
|
| 26 |
+
|
| 27 |
+
## Use
|
| 28 |
+
|
| 29 |
+
```swift
|
| 30 |
+
// Package.swift → .package(url: "https://github.com/xocialize/mlx-edgetam-swift", from: "0.1.0")
|
| 31 |
+
import EdgeTAM
|
| 32 |
+
let predictor = try EdgeTAMPredictor.fromPretrained(weightsPath, dtype: .float16)
|
| 33 |
+
predictor.setImage(sourceCGImage)
|
| 34 |
+
let (mask, score, _, _) = predictor.predict(point: (500, 375)) // click → object mask
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
Or as an MLXEngine `promptSegment` ModelPackage (`MLXEdgeTAM.EdgeTAMPackage`), resolving this repo via the Hub.
|
| 38 |
+
|
| 39 |
+
Weights: Apache-2.0 (facebookresearch/EdgeTAM). Port code: MIT.
|