Instructions to use litert-community/YOLACT-ResNet50-LiteRT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/YOLACT-ResNet50-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
Measured on device (edge-compat): Galaxy S26 · LiteRT 2.2.0 · GPU (ML Drift) · 38.4 ms p50 (2026-08-26); Galaxy S26 · LiteRT 2.2.0 · NPU (QNN/HTP) · 14.3 ms p50 (2026-08-26); Raspberry Pi 5 · LiteRT 2.2.0.dev20260804 · CPU/XNNPACK, 4 threads · 1096 ms p50 (2026-08-31); browser · Chromium 151 on M4 Max · LiteRT.js 2.5.3 · WebGPU · 63.1 ms p50 · output matches CPU (2026-08-11). Record: https://github.com/john-rocky/edge-compat/blob/main/cards/yolact-resnet50/CARD.md
YOLACT-ResNet50 — LiteRT (real-time instance segmentation, GPU)
On-device real-time instance segmentation running fully on the LiteRT
CompiledModel GPU delegate (no CPU fallback). YOLACT
(ICCV 2019) predicts per-instance COCO masks. The network (ResNet50 + FPN +
protonet + heads) runs on the GPU; the lightweight decode (NMS + linear-combination
masks) runs host-side. ~41 ms/graph on a Pixel 8a.
- Architecture: YOLACT-ResNet50 (base, no deformable conv) — pure CNN.
- Weights: dbolya/yolact (
yolact_resnet50_54_800000) · MIT. - Size: 125 MB.
Files
yolact.tflite— the GPU graph (input[1,3,550,550]NCHW).priors.bin— 19248 SSD priors[cx,cy,w,h](float32) used by the host-side box decode.
I/O
- Input:
[1, 3, 550, 550]NCHW, BGR, normalized(x - [103.94,116.78,123.68]) / [57.38,57.12,58.40](no /255). - Raw outputs:
loc [1,19248,4],conf [1,19248,81](softmax, incl. background),mask [1,19248,32](coefficients),proto [1,138,138,32](prototype masks).
Host-side decode
- Boxes: SSD
decode(loc, priors, variances=[0.1,0.2]). - NMS: per-class, score-threshold ~0.3, IoU 0.5, top-k.
- Masks (lincomb): for each kept detection,
mask = sigmoid(proto @ coeff)→ crop to the box → threshold 0.5 → upscale.
GPU conversion
Base YOLACT is a pure CNN, so the graph converts fully GPU-compatible (138/138
nodes on the delegate, 1 partition; device corr 0.99999–1.0 vs PyTorch on all four
raw outputs) with one patch: the ResNet50 stem MaxPool2d(padding=1) lowers to a
-inf PADV2 (rejected by Mali), replaced by a 0-pad + unpadded maxpool (exact
post-ReLU). The scripted FPN is made traceable by disabling YOLACT's JIT
(use_jit=False). CPU-exact vs PyTorch (corr 1.0).
Minimal usage
Kotlin (Android, LiteRT CompiledModel GPU)
val options = CompiledModel.Options(Accelerator.GPU)
val model = CompiledModel.create(context.assets, "yolact.tflite", options, null)
val inBufs = model.createInputBuffers()
val outBufs = model.createOutputBuffers() // map by size: loc=N*4, conf=N*81, mask=N*32, proto=138*138*32
inBufs[0].writeFloat(inputNCHW) // [1,3,550,550] BGR, (x-[103.94,116.78,123.68])/[57.38,57.12,58.40]
model.run(inBufs, outBufs)
val loc = outBufs[iLoc].readFloat() // [19248*4]
val conf = outBufs[iConf].readFloat() // [19248*81] (softmax)
val mask = outBufs[iMask].readFloat() // [19248*32] coefficients
val proto = outBufs[iProto].readFloat() // [138*138*32] prototypes
// host-side decode (priors.bin bundled as an asset):
// box = SSD-decode(loc, priors, variances=[0.1,0.2]); per-class NMS (score 0.3, IoU 0.5);
// per kept det: mask = sigmoid(proto @ coeff) (>0) cropped to the box.
// Full implementation: YolactSegmenter.kt in the sample app.
Python (LiteRT / ai-edge-litert)
import numpy as np
from ai_edge_litert.interpreter import Interpreter
it = Interpreter(model_path="yolact.tflite"); it.allocate_tensors()
inp, out = it.get_input_details(), it.get_output_details()
it.set_tensor(inp[0]["index"], x) # [1,3,550,550] BGR, normalized (see above)
it.invoke()
outs = {tuple(o["shape"][1:]): it.get_tensor(o["index"])[0] for o in out}
loc = outs[(19248, 4)]; conf = outs[(19248, 81)]
mask = outs[(19248, 32)]; proto = outs[(138, 138, 32)]
priors = np.fromfile("priors.bin", np.float32).reshape(-1, 4)
cxy = priors[:, :2] + loc[:, :2] * 0.1 * priors[:, 2:]
wh = priors[:, 2:] * np.exp(loc[:, 2:] * 0.2)
boxes = np.concatenate([cxy - wh / 2, cxy + wh / 2], 1) # x1y1x2y2 (0..1)
# then per-class NMS on conf, and mask_i = sigmoid(proto @ mask[i]) cropped to boxes[i]
Performance
Measured on a Pixel 8a (Tensor G3, Android 16) with the standard TFLite benchmark_model tool — 10 warm-up runs then 50 timed runs, reported as the tool's mean.
| Runtime | Backend | Graph on GPU | Latency |
|---|---|---|---|
LiteRT CompiledModel (LITERT_CL) |
GPU | 138 / 138 | ~41 ms |
TFLite benchmark_model (TfLiteGpuDelegateV2) |
GPU (OpenCL) | 138 / 138 | 130.4 ms |
TFLite benchmark_model |
CPU (XNNPACK, 4 threads) | — | 1426.2 ms |
The two GPU rows are different runtimes, not a contradiction. The LITERT_CL figure is the one recorded when this model shipped, taken through LiteRT's own CompiledModel accelerator — the path the Kotlin sample app and the LiteRT API use. The TfLiteGpuDelegateV2 figure is the classic TFLite OpenCL delegate, measured with a tool anyone can download and re-run. They agree on how much of the graph the GPU takes; they disagree on speed, and the classic delegate is the slower of the two here. Read the TfLiteGpuDelegateV2 row as a reproducible floor, not as this model's speed on LiteRT.
Snapdragon NPU (Hexagon)
The NPU is 2.67x faster than the GPU (14.34 ms against 38.37 ms) and loads 13.02x faster (158 ms against 2060 ms).
| backend | compiled | inference (median / min) | load |
|---|---|---|---|
| NPU (Hexagon v81) | on-device JIT | 14.34 ms / 13.89 ms | 158 ms |
| GPU (Adreno) | — | 38.37 ms / 31.57 ms | 2060 ms |
Measured on a Samsung Galaxy S26 (Snapdragon 8 Elite Gen 5 / SM8850, Hexagon v81, Android 16) with LiteRT CompiledModel 2.2.0, one accelerator per process, 5 warm-up runs then N=50 timed runs, median reported. Every run held thermal status NONE throughout. Headroom 0.77, where 1.0 is the throttling threshold.
The NPU rows ran the published file unchanged. LiteRT compiled it for the Hexagon on the device at first load. That first compile took 12 s here. The load column above is the cached load every later run pays. Recipe and the runtime libraries it needs: NPU guide.
GPU wiring: GPU guide.
Raspberry Pi 5 (CPU)
Measured on a Raspberry Pi 5 Model B Rev 1.1 (8 GB, Raspberry Pi OS 64-bit) with the LiteRT benchmark_model tool from litert-cli-nightly 0.2.0.dev20260805: CPU inference (XNNPACK, 4 threads), 3 invocations per file of 10 warm-up plus 50 timed runs (the tool caps a phase at 150 s, so very slow graphs run fewer — the Runs column is the actual timed total). The latency is the median across invocations; the spread is the min–max over all timed runs. No thermal throttling occurred during these runs (vcgencmd get_throttled stayed 0x0).
| File | Inference (median) | Spread (min–max) | Runs | Peak memory |
|---|---|---|---|---|
yolact.tflite |
1,095.6 ms | 1,077.6–1,107.9 ms | 150 | 376 MB |
License
MIT (YOLACT / dbolya/yolact). COCO class taxonomy.
- Downloads last month
- 74
