Instructions to use tepirale/sam3-LiteRT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use tepirale/sam3-LiteRT 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
- Notebooks
- Google Colab
- Kaggle
SAM 3 路 LiteRT (.tflite) (fp32 / fp16 / int8 / w8 / q4 / w4)
Conversi贸n de facebook/sam3 con litert-torch y cuantizaci贸n con litert-quantizer.
Archivos
| variante | vision_encoder | text_encoder | prompt_decoder |
|---|---|---|---|
fp32 |
1.7 GB | 1.3 GB | 128.7 MB |
fp16 |
869.1 MB | 675.0 MB | 83.4 MB |
int8 |
441.5 MB | 341.5 MB | 61.2 MB |
w8 |
441.6 MB | 341.6 MB | 61.3 MB |
q4 |
241.6 MB | 173.2 MB | 50.0 MB |
w4 |
241.7 MB | 173.4 MB | 49.9 MB |
| sufijo | qu茅 es |
|---|---|
fp16 |
pesos fp16, c贸mputo fp32 |
int8 |
din谩mica int8 (pesos por canal + activaciones cuantizadas en ejecuci贸n) |
w8 |
solo pesos int8 (c贸mputo float, m谩s fiel) |
q4 |
din谩mica int4 por canal |
w4 |
solo pesos int4 por canal |
Entradas / salidas
| grafo | entradas | salidas |
|---|---|---|
vision_encoder |
pixel_values [B,3,1008,1008] float32 |
fpn_hidden_state_0 [B,256,288,288], _1 [B,256,144,144], _2 [B,256,72,72] |
text_encoder |
input_ids, attention_mask [B,32] |
text_features [B,32,256] |
prompt_decoder |
fpn_hidden_state_0/1/2, text_features, attention_mask |
pred_masks [B,200,288,288] (logits), pred_boxes [B,200,4] xyxy normalizado, pred_logits [B,200], presence_logits [B,1], semantic_seg [B,1,288,288] |
Score de cada consulta = sigmoid(pred_logits) * sigmoid(presence_logits). El preprocesado (resize 1008, normalizaci贸n) y el tokenizer (CLIP, max_length=32, padding="max_length") vienen en este repo v铆a Sam3Processor.
En LiteRT input_ids y attention_mask son int32, y las salidas se llaman output_0鈥 en el mismo orden que la tabla (ver manifest.json).
Validaci贸n (imagen COCO, prompt "cat")
| variante | objetos (ref) | IoU m谩scara vs PyTorch | 螖 score m谩x |
|---|---|---|---|
fp32 |
1 (1) | 1.0 | 0.0 |
fp16 |
1 (1) | 1.0 | 0.0 |
int8 |
1 (1) | 0.9981 | 0.0016 |
w8 |
1 (1) | 0.9995 | 0.0003 |
q4 |
1 (1) | 0.9923 | 0.0287 |
w4 |
1 (1) | 0.9927 | 0.0304 |
Uso (Python, ai-edge-litert)
import numpy as np
from huggingface_hub import hf_hub_download
from ai_edge_litert.interpreter import Interpreter
from transformers import Sam3Processor
from PIL import Image
repo, v = "tepirale/sam3-LiteRT", "_q4"
proc = Sam3Processor.from_pretrained(repo)
R = lambda n: Interpreter(model_path=hf_hub_download(repo, f"{n}{v}.tflite")).get_signature_runner()
o = lambda d: [d[k] for k in sorted(d, key=lambda s: int(s.split("_")[-1]))]
image = Image.open("foto.jpg").convert("RGB")
pv = proc(images=image, return_tensors="np")["pixel_values"].astype(np.float32)
tok = proc.tokenizer("cat", padding="max_length", max_length=32, truncation=True, return_tensors="np")
ids, am = tok["input_ids"].astype(np.int32), tok["attention_mask"].astype(np.int32)
fpn = o(R("vision_encoder")(pixel_values=pv))
tf = o(R("text_encoder")(input_ids=ids, attention_mask=am))[0]
pred_masks, pred_boxes, pred_logits, presence_logits, semantic_seg = o(R("prompt_decoder")(
fpn_hidden_state_0=fpn[0], fpn_hidden_state_1=fpn[1], fpn_hidden_state_2=fpn[2], text_features=tf, attention_mask=am))
En Android/iOS usa CompiledModel / Interpreter de LiteRT con los mismos nombres de firma.
Licencia
Pesos derivados de facebook/sam3, publicados por Meta bajo la SAM License (no Apache-2.0). Revisa y acepta sus t茅rminos antes de usar o redistribuir.
- Downloads last month
- 92
Inference Providers NEW
This model isn't deployed by any Inference Provider. 馃檵 Ask for provider support
Model tree for tepirale/sam3-LiteRT
Base model
facebook/sam3