Views
No views yet
CompiledModel
GPU delegate (no CPU fallback). DIS (ECCV 2022) is a
high-accuracy IS-Net that cuts out the main object with fine structure detail (thin
stems, petals, wires, handles) — for e-commerce product photos and graphics. ~11 ms/frame
on a Pixel 8a.isnet-general-use · Apache-2.0.
[1, 3, 1024, 1024] NCHW, RGB, x/255 - 0.5.[1, 1, 1024, 1024] sigmoid mask (0–1) — resize to the image, use as alpha.align_corners=True → False on the bilinear upsamples. CPU-exact vs PyTorch
(max|diff| 0.0).1val options = CompiledModel.Options(Accelerator.GPU)
2val model = CompiledModel.create(context.assets, "dis.tflite", options, null)
3val inBufs = model.createInputBuffers()
4val outBufs = model.createOutputBuffers()
5
6inBufs[0].writeFloat(inputNCHW) // [1,3,1024,1024] RGB, x/255 - 0.5
7model.run(inBufs, outBufs)
8val mask = outBufs[0].readFloat() // [1024*1024] alpha (0..1); resize -> composite1import numpy as np
2from ai_edge_litert.interpreter import Interpreter
3
4it = Interpreter(model_path="dis.tflite"); it.allocate_tensors()
5inp, out = it.get_input_details(), it.get_output_details()
6it.set_tensor(inp[0]["index"], x) # [1,3,1024,1024] float32, RGB, x/255 - 0.5
7it.invoke()
8mask = it.get_tensor(out[0]["index"])[0, 0] # [1024,1024] alpha 0..1build_dis.py): loads the Apache-2.0 IS-Net general-use
weights and exports the main mask.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 | 247 / 247 | ~11 ms |
TFLite benchmark_model (TfLiteGpuDelegateV2) | GPU (OpenCL) | 247 / 247 | 240.5 ms |
TFLite benchmark_model | CPU (XNNPACK, 4 threads) | — | 4868.4 ms |
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.| backend | inference (median / min) | load |
|---|---|---|
| NPU (Hexagon v81) | 24.21 ms / 23.96 ms | 192 ms |
| GPU (Adreno) | 72.43 ms / 71.86 ms | 1264 ms |
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.69-0.71, where 1.0 is the throttling threshold.