Instructions to use litert-community/ormbg-LiteRT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/ormbg-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
ormbg — Open Remove-Background (LiteRT GPU)
On-device background removal running fully on the LiteRT CompiledModel GPU
delegate (no CPU fallback). ormbg is a
fully open, Apache-2.0 foreground/alpha matte model (an ISNet trained for
photorealistic subject cut-out) — the permissively-licensed alternative to the
non-commercial RMBG-1.4. 246 ms per 1024² frame on a Pixel 8a (2026-09-05, run + readback).
- Architecture: ISNet (RSU / U²-Net-style nested residual blocks) — pure CNN.
- Weights: schirrmacher/ormbg · Apache-2.0.
- Size: 176 MB.
Input (left) → alpha cut-out on transparency (right). Subject photo: Unsplash (free license).
I/O
- Input:
[1, 3, 1024, 1024]NCHW, RGB,x / 255(no mean/std). - Output:
[1, 1, 1024, 1024]alpha matte in[0,1]. Post-process: min-max normalize, resize to the original size, use as the foreground alpha.
GPU conversion
ormbg is a pure CNN (ISNet RSU blocks). It converts fully GPU-compatible (246/246
nodes on the delegate, 1 partition; device corr 0.999881) with one
defensive patch: align_corners=True → False on the bilinear upsamples (the GPU
delegate rejects align_corners=True). CPU-exact vs PyTorch (corr 0.9999999999).
Minimal usage
Kotlin (Android, LiteRT CompiledModel GPU)
val options = CompiledModel.Options(Accelerator.GPU)
val model = CompiledModel.create(context.assets, "ormbg.tflite", options, null)
val inBufs = model.createInputBuffers()
val outBufs = model.createOutputBuffers()
inBufs[0].writeFloat(inputNCHW) // [1,3,1024,1024] RGB, x/255
model.run(inBufs, outBufs)
val mask = outBufs[0].readFloat() // [1024*1024] alpha; min-max normalize -> foreground alpha
Python (LiteRT / ai-edge-litert)
import numpy as np
from ai_edge_litert.interpreter import Interpreter
it = Interpreter(model_path="ormbg.tflite"); it.allocate_tensors()
inp, out = it.get_input_details(), it.get_output_details()
it.set_tensor(inp[0]["index"], x) # [1,3,1024,1024] float32, RGB, x/255
it.invoke()
m = it.get_tensor(out[0]["index"])[0, 0] # [1024,1024] alpha
m = (m - m.min()) / (m.max() - m.min()) # normalize; resize to original, composite
Add it to your Android app
One dependency, one file, one model download — the recipe for an app that already exists is
ormbg/INTEGRATION.md
(machine-readable: recipe.json).
Copy BgRemover.kt, then:
implementation("com.google.ai.edge.litert:litert:2.2.0") // build.gradle.kts, plus androidResources { noCompress += "tflite" }
val remover = BgRemover.fromAssets(context) // once, off the main thread (~2.6 s: GPU compile + warm-up)
val cutout = remover.process(photo)?.cutout(photo) // Bitmap with a transparent background
remover.close() // on teardown; remover.cancel() aborts a call in flight
Verified 2026-09-05 on a Pixel 8a (Android 16, LiteRT 2.2.0): 246/246 nodes on the GPU, 246 ms per
1024² image (median of 20, run + readback, thermal status 0), 361 ms including pre/post-processing;
device output vs host CPU fp32 on the same input: corr 1.000000, max |diff| 0.00905. The recipe ships an
instrumented test that reproduces these values on your device. Provenance: converted with litert-torch
0.9.4 by john-rocky (build_ormbg.py,
re-run 2026-09-05, byte-identical to this file); recipe and measurements in
john-rocky/LiteRT-Models.
Conversion
Converted with litert-torch (build_ormbg.py): loads the ISNet weights and exports.
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 | 246 / 246 | 246 ms (median of 20, run + readback, 2026-09-05) |
TFLite benchmark_model (TfLiteGpuDelegateV2) |
GPU (OpenCL) | 246 / 246 | 244.4 ms |
TFLite benchmark_model |
CPU (XNNPACK, 4 threads) | — | 5263.2 ms |
The two GPU rows now agree: the classic delegate's 244.4 ms and CompiledModel's 246 ms are the same work. An earlier version of this card quoted ~10 ms for the CompiledModel row; that number timed the asynchronous run() call alone.
Snapdragon NPU (Hexagon)
This file runs on the Qualcomm Hexagon NPU as published — no conversion and no pre-compiled artifact. LiteRT compiles it on the device and caches the result.
Measured on a physical Samsung Galaxy S26 (Snapdragon 8 Elite Gen 5 / SM8850,
Hexagon v81) with LiteRT CompiledModel 2.2.0 — 5 warm-up runs then 50 timed runs, one
accelerator per process, every row taken at device thermal status NONE.
| Compute unit | Inference (median / min) | Load | Start headroom |
|---|---|---|---|
| NPU (Hexagon) — first launch | 24.45 ms / 23.76 ms | 11606 ms | 0.60 |
| NPU (Hexagon) — cached | 23.95 ms / 23.85 ms | 363 ms | 0.62 |
| GPU (Adreno) | 74.42 ms / 73.44 ms | 1178 ms | 0.62 |
The NPU is 3.1x faster on inference here (23.95 ms against 74.42 ms). The first launch pays once for on-device compilation; every launch after that loads in 363 ms against 1178 ms for the GPU (3.2x), because the GPU rebuilds its shaders each time. The file is fp16 and needs no int8 quantization to reach the NPU.
Running it on the NPU
Put these in jniLibs/arm64-v8a/. None of them are distributed from this repository —
the first two come from Google, the rest from Qualcomm's own SDK:
| Library | Source |
|---|---|
libLiteRtDispatch_Qualcomm.so, libLiteRtCompilerPlugin_Qualcomm.so |
litert_npu_runtime_libraries_jit.zip, a release asset of google-ai-edge/LiteRT |
libQnnHtp.so, libQnnSystem.so, libQnnHtpV81Stub.so, libQnnHtpV81Skel.so, libQnnHtpPrepare.so, libQnnIr.so, libQnnSaver.so |
Qualcomm QAIRT — the same zip ships fetch_qualcomm_library.sh, which downloads the SDK and copies them for you |
Pick the runtime matching the device's Hexagon version: SM8550 → v73, SM8650 → v75, SM8750 → v79, SM8850 → v81.
val env = Environment.create(
context,
mapOf(
Environment.Option.DispatchLibraryDir to context.applicationInfo.nativeLibraryDir,
// Required for on-device compilation. Without it the model silently runs on CPU.
Environment.Option.CompilerPluginLibraryDir to context.applicationInfo.nativeLibraryDir,
),
)
val options = CompiledModel.Options(Accelerator.NPU).apply {
qualcommOptions = CompiledModel.QualcommOptions(
htpPerformanceMode = CompiledModel.QualcommOptions.HtpPerformanceMode.BURST
)
}
val model = CompiledModel.create(context.assets, "ormbg.tflite", options, env)
Build settings: useLegacyPackaging = true under packaging { jniLibs { … } }, so the
DSP can open the skel from a real path, and Kotlin 2.3+ for LiteRT 2.2.0's metadata.
Every NPU failure here is silent. There is no error when the NPU is unavailable — you get a plausible CPU number instead. Confirm from logcat which delegate took the graph:
Replacing 1 out of 1 node(s) with delegate (DispatchDelegate)is the NPU, while... (TfLiteXNNPackDelegate)is the CPU. A missing library is reported only as aW-leveldlopen failedline under a genericNo compiler plugin foundsummary.
On the conditions. Thermal headroom is reported as measured, where 1.0 is the
throttling threshold. All rows were taken at a comparable headroom and compare directly;
figures taken at a different headroom will differ. Each accelerator ran in its own
process, because LiteRT's Environment is shared within one and the first model load
fixes the options for every later one.
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 |
|---|---|---|---|---|
ormbg.tflite |
2,989.1 ms | 2,918.3–3,178.0 ms | 150 | 941 MB |
License
Apache-2.0 (ormbg / schirrmacher). ISNet architecture.
- Downloads last month
- 95
Model tree for litert-community/ormbg-LiteRT
Base model
schirrmacher/ormbg