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.

ormbg background removal

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.

License

Apache-2.0 (ormbg / schirrmacher). ISNet architecture.

Downloads last month
13
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support