Mask Generation
LiteRT
LiteRT
sam2
segment-anything
mask-decoder
interactive-segmentation
on-device
gpu
Instructions to use litert-community/SAM2.1-Hiera-Tiny-Mask-Decoder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/SAM2.1-Hiera-Tiny-Mask-Decoder with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- sam2
How to use litert-community/SAM2.1-Hiera-Tiny-Mask-Decoder with sam2:
# Use SAM2 with images import torch from sam2.sam2_image_predictor import SAM2ImagePredictor predictor = SAM2ImagePredictor.from_pretrained("litert-community/SAM2.1-Hiera-Tiny-Mask-Decoder") 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("litert-community/SAM2.1-Hiera-Tiny-Mask-Decoder") 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
Commit History
10 days ago
-
README: link the browser demo (static Space litert-community/sam2-1-tiny-click-to-segment, LiteRT.js)
Verified signature049c250
-
Card: measured device / browser results (edge-compat, 2026-09)
Verified signature5eb2a03
-
Card: base_model_relation: quantized (list under the base model's Quantizations)
Verified signaturea0f7cac
-
Add measured Raspberry Pi 5 (CPU) section
Verified signatureNumbers from the 2026-08-31 Raspberry Pi 5 sweep: LiteRT benchmark_model (litert-cli-nightly 0.2.0.dev20260805), CPU/XNNPACK, 4 threads, 10 warm-up + 50 timed runs x 3 invocations per file, cooldown between invocations, thermal throttle state verified 0x0 on every run. Median + spread, never single-shot. Measurements are joined to this repo by exact .tflite file name.30949fc
-
Replace the unsourced ~7 ms/tap with a measured Pixel 8a CompiledModel run
Verified signatureThe card claimed 'Pixel 8a - fully GPU (LITERT_CL), correct masks, ~7 ms/tap' and no primary log survived for that configuration. Measured on the phone it names, with the API it names: full delegation is confirmed (425/425 and 378/378 LITERT_CL nodes), the latency is not -- 30.88 ms for the v2 build, 4.3x the claim. A same-phone CPU control (222.8 ms) and the Galaxy S26 row (10.55 ms) are quoted beside it. LiteRT CompiledModel 2.2.0, one accelerator per process, 5 warm-up then N=50 timed, median, every row at thermal NONE throughout. Primary log: litertlm-convert/community_accel_work/s6_p8a/results.jsonl.e1692f3 -
Correct the encoder latency this card attributed to ~7 ms
Verified signatureThe ~7 ms in this line described this decoder, not the encoder. The S26 sweep measures the encoder at 208.0 ms on the GPU against this decoder's 10.08 ms on the same phone, so the encoder cannot have run in 7 ms on a slower one. Primary log: litertlm-convert/community_accel_work/s2_npu_sweep/results.jsonl.c6a9f30 -
Add measured Galaxy S26 NPU/GPU section
Verified signatureNumbers from the S26 classic sweep. Primary logs: litertlm-convert/community_accel_work/s2_npu_sweep/results.jsonl (on-device JIT) and portal_work/bench_all.txt + bench_redo.txt (the 2026-08-23 AOT sweep); every row states which of the two produced it. Rows carry device, SoC, runtime, N and thermal state, and join to this repo by exact .tflite file name. Rows taken outside the sweep's thermal window are not reported.08aa12f
-
Card: correct the GPU node counts — the previous figures added the XNNPACK fallback partition to the GPU delegate partition
Verified signaturecc31678
-
Card: add a measured Performance table (Pixel 8a, benchmark_model GPU+CPU), naming the runtime for each row
Verified signature06d0159
-
Document the rank-3 attention GPU miscompute and the v2 fix
Verified signatureb7a4afe -
Add v2 mask decoder: rank-4 attention (GPU-correct, ~20% faster)
Verified signaturef6a798a
-
Add minimal usage snippets and hero image
Verified signaturee058a71
-
Add interactive segmentation demo (hero, picker trimmed)
Verified signature8542eec -
Remove demo (re-record without the photo picker)
Verified signature5ce1690 -
Add interactive segmentation demo (hero)
Verified signaturef03b21d -
Mirror the conversion script
Verified signaturea8e7c27 -
Add host prompt-encoder constants
Verified signature1c44fa6 -
Add model card
Verified signature0eee160 -
Add SAM 2.1 Hiera-Tiny mask decoder (FP16, GPU-clean)
Verified signature6817b39 -
initial commit
Verified signature0abb2fe