DIS-ISNet-LiteRT / README.md
mlboydaisuke's picture
Upload README.md with huggingface_hub
ed21057 verified
|
Raw
History Blame Contribute Delete
2.6 kB
---
license: apache-2.0
library_name: litert
pipeline_tag: image-segmentation
tags:
- litert
- tflite
- android
- on-device
- gpu
- dichotomous-segmentation
- salient-object
- cutout
- isnet
---
# DIS (IS-Net, general-use) — High-precision object cutout (LiteRT GPU)
On-device **dichotomous image segmentation** running **fully on the LiteRT `CompiledModel`
GPU** delegate (no CPU fallback). [DIS](https://github.com/xuebinqin/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.
- **Architecture:** IS-Net (RSU / U²-Net-style nested residual blocks) — pure CNN.
- **Weights:** [xuebinqin/DIS](https://github.com/xuebinqin/DIS) `isnet-general-use` · Apache-2.0.
- **Size:** 176 MB.
![DIS high-precision cutout](hero.png)
*Input (left) → high-precision alpha cut-out on transparency (right). Photo: Unsplash (free license).*
## I/O
- **Input:** `[1, 3, 1024, 1024]` NCHW, RGB, `x/255 - 0.5`.
- **Output:** `[1, 1, 1024, 1024]` sigmoid mask (0–1) — resize to the image, use as alpha.
## GPU conversion
DIS is a pure CNN (IS-Net RSU blocks). It converts fully GPU-compatible (**247/247 nodes
on the delegate, 1 partition**; device max|diff| 0.00034, ~11 ms) with **one defensive
patch**: `align_corners=True` → `False` on the bilinear upsamples. CPU-exact vs PyTorch
(max|diff| 0.0).
## Minimal usage
### Kotlin (Android, LiteRT CompiledModel GPU)
```kotlin
val options = CompiledModel.Options(Accelerator.GPU)
val model = CompiledModel.create(context.assets, "dis.tflite", options, null)
val inBufs = model.createInputBuffers()
val outBufs = model.createOutputBuffers()
inBufs[0].writeFloat(inputNCHW) // [1,3,1024,1024] RGB, x/255 - 0.5
model.run(inBufs, outBufs)
val mask = outBufs[0].readFloat() // [1024*1024] alpha (0..1); resize -> composite
```
### Python (LiteRT / ai-edge-litert)
```python
import numpy as np
from ai_edge_litert.interpreter import Interpreter
it = Interpreter(model_path="dis.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 - 0.5
it.invoke()
mask = it.get_tensor(out[0]["index"])[0, 0] # [1024,1024] alpha 0..1
```
## Conversion
Converted with **litert-torch** (`build_dis.py`): loads the Apache-2.0 IS-Net general-use
weights and exports the main mask.
## License
Apache-2.0 (DIS / xuebinqin). IS-Net architecture.