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. ~10 ms/frame on a Pixel 8a.
- 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, ~10 ms) 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
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 | ~10 ms |
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 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.
License
Apache-2.0 (ormbg / schirrmacher). ISNet architecture.
- Downloads last month
- 56
