Instructions to use cstr/sam2.1-hiera-tiny-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sam2
How to use cstr/sam2.1-hiera-tiny-GGUF with sam2:
# Use SAM2 with images import torch from sam2.sam2_image_predictor import SAM2ImagePredictor predictor = SAM2ImagePredictor.from_pretrained("cstr/sam2.1-hiera-tiny-GGUF") 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("cstr/sam2.1-hiera-tiny-GGUF") 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
SAM 2.1 Hiera-tiny, GGUF (image mode)
GGUF conversion of Meta's SAM 2.1 Hiera-tiny for
CrispEmbed's ggml SAM 2.1 engine (src/sam2.cpp,
C API crispembed_sam2_*): single-image segmentation with point and box prompts. The video-memory
parts of SAM 2 are not included. Used by the sam mask provider of
Crisp 3D Studio.
| File | Precision | Size | SHA-256 |
|---|---|---|---|
sam2.1-hiera-tiny-f16.gguf |
F16 (recommended) | 62.9 MB | b1e5c7a8d548f8545fb60a002883cb089aa5290ab6a2c549a0b4750f31b4fb39 |
sam2.1-hiera-tiny-f32.gguf |
F32 | 125 MB | 02ac9814abfe82ab5584b881f9137af39a1d364c855c1143f587f8dd5d73d901 |
Converted with models/convert-sam2-to-gguf.py in CrispEmbed (296 tensors; the trunk's bicubic
position-embedding resize is stored as a 256×7 resampling matrix, so the runtime needs no bicubic code).
F16 is lossless against F32 (encoder cosine ≥ 0.999999, logits 1.000000, identical masks) at half the size. Q8_0 was measured and not published: one of the four mask outputs dropped to IoU 0.9895 against PyTorch; Q4_K is unusable for this model.
Verification
CrispEmbed's test-sam2-diff against PyTorch 2.7 on the CPU, one 1749×1155 photo with a box,
four object points and one background point: cosine 1.000000 at every stage (patch embedding, all
12 Hiera blocks, FPN, the three decoder inputs, mask logits), largest difference 3.6e-5 on the mask
logits, scores exact, the four masks identical (25 of 25 checks pass).
Compare against PyTorch on the CPU, not Apple's MPS backend: PyTorch 2.7 on MPS computes the strided
query max_pool2d in the Hiera encoder incorrectly (a contiguous copy before the pool fixes it).
License
Apache-2.0, as the original model: SAM 2 is Copyright Meta Platforms, Inc. and affiliates. This
repository redistributes converted weights under the same license (see LICENSE); the conversion
changes the format only, not the weights.
ONNX export of the same model: cstr/sam2.1-hiera-tiny-ONNX.
- Downloads last month
- 44
16-bit
32-bit
Model tree for cstr/sam2.1-hiera-tiny-GGUF
Base model
facebook/sam2.1-hiera-tiny