eisneim commited on
Commit
1b7b988
·
verified ·
1 Parent(s): 1c9193e

Upload folder using huggingface_hub

Browse files
.DS_Store ADDED
Binary file (6.15 kB). View file
 
README.md CHANGED
@@ -1,3 +1,79 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ pipeline_tag: image-segmentation
5
+ tags:
6
+ - sam2
7
+ - segment-anything
8
+ - mlx
9
+ - apple-silicon
10
+ - video-segmentation
11
+ - object-tracking
12
+ license: apache-2.0
13
+ ---
14
+
15
+ # SAM2.1 MLX Weights
16
+
17
+ MLX-format weights for [SAM2.1 (Segment Anything Model 2.1)](https://github.com/facebookresearch/sam2) ported to Apple MLX.
18
+
19
+ ## Quick Start
20
+
21
+ **1. Clone the code:**
22
+ ```bash
23
+ git clone https://github.com/eisneim/sam2.1_mlx.git
24
+ cd sam2.1_mlx
25
+ pip install mlx opencv-python safetensors numpy
26
+ ```
27
+
28
+ **2. Download weights from this repo:**
29
+
30
+ ```bash
31
+ # Base Plus (recommended, best quality/speed balance)
32
+ huggingface-cli download eisneim/sam2.1_mlx_weights sam2.1_hiera_base_plus.safetensors --local-dir weights/
33
+
34
+ # Small (faster, slightly lower quality)
35
+ huggingface-cli download eisneim/sam2.1_mlx_weights sam2.1_hiera_small.safetensors --local-dir weights/
36
+ ```
37
+
38
+ Or manually download the `.safetensors` files and place them in `weights/`.
39
+
40
+ **3. Run:**
41
+
42
+ ```bash
43
+ # Video tracking — click on an object in the first frame
44
+ python inference_video.py -i your_video.mp4
45
+
46
+ # Image segmentation — click on an object
47
+ python inference_image.py -i your_image.jpg
48
+
49
+ # Use the small model
50
+ python inference_video.py -i your_video.mp4 --model small
51
+ ```
52
+
53
+ ## Available Models
54
+
55
+ | Model | File | Size | Quality | Speed |
56
+ |-------|------|------|---------|-------|
57
+ | base_plus | `sam2.1_hiera_base_plus.safetensors` | ~300MB | Best | ~130 fps |
58
+ | small | `sam2.1_hiera_small.safetensors` | ~150MB | Good | ~200 fps |
59
+
60
+ ## Converting Weights Yourself
61
+
62
+ If you prefer to convert from the original PyTorch checkpoints:
63
+
64
+ ```bash
65
+ # Download PyTorch weights from Meta
66
+ wget https://dl.fbaipublicfiles.com/segment_anything_2/092824/sam2.1_hiera_base_plus.pt -P weights/
67
+
68
+ # Convert to MLX safetensors
69
+ python -m src.sam2.convert --src weights/sam2.1_hiera_base_plus.pt --dst weights/sam2.1_hiera_base_plus.safetensors
70
+ ```
71
+
72
+ ## Links
73
+
74
+ - **Code:** https://github.com/eisneim/sam2.1_mlx
75
+ - **Original SAM2:** https://github.com/facebookresearch/sam2
76
+
77
+ ## License
78
+
79
+ Apache 2.0 (same as the original SAM2).
sam2.1_hiera_base_plus.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:80d5c62aa0a608017ba0e664667580ddc2ea8c52a2fccc86b4f1040b3f9fa232
3
+ size 323473304
sam2.1_hiera_small.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0b3a0198309acc9d1879d0a78aedc4adea10cf2fa9ff6ab173872fc6f4ae3eef
3
+ size 184302864