mlboydaisuke commited on
Commit
ed21057
·
verified ·
1 Parent(s): 9420440

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +80 -0
README.md ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: litert
4
+ pipeline_tag: image-segmentation
5
+ tags:
6
+ - litert
7
+ - tflite
8
+ - android
9
+ - on-device
10
+ - gpu
11
+ - dichotomous-segmentation
12
+ - salient-object
13
+ - cutout
14
+ - isnet
15
+ ---
16
+
17
+ # DIS (IS-Net, general-use) — High-precision object cutout (LiteRT GPU)
18
+
19
+ On-device **dichotomous image segmentation** running **fully on the LiteRT `CompiledModel`
20
+ GPU** delegate (no CPU fallback). [DIS](https://github.com/xuebinqin/DIS) (ECCV 2022) is a
21
+ high-accuracy IS-Net that cuts out the main object with **fine structure detail** (thin
22
+ stems, petals, wires, handles) — for e-commerce product photos and graphics. ~11 ms/frame
23
+ on a Pixel 8a.
24
+
25
+ - **Architecture:** IS-Net (RSU / U²-Net-style nested residual blocks) — pure CNN.
26
+ - **Weights:** [xuebinqin/DIS](https://github.com/xuebinqin/DIS) `isnet-general-use` · Apache-2.0.
27
+ - **Size:** 176 MB.
28
+
29
+ ![DIS high-precision cutout](hero.png)
30
+
31
+ *Input (left) → high-precision alpha cut-out on transparency (right). Photo: Unsplash (free license).*
32
+
33
+ ## I/O
34
+
35
+ - **Input:** `[1, 3, 1024, 1024]` NCHW, RGB, `x/255 - 0.5`.
36
+ - **Output:** `[1, 1, 1024, 1024]` sigmoid mask (0–1) — resize to the image, use as alpha.
37
+
38
+ ## GPU conversion
39
+
40
+ DIS is a pure CNN (IS-Net RSU blocks). It converts fully GPU-compatible (**247/247 nodes
41
+ on the delegate, 1 partition**; device max|diff| 0.00034, ~11 ms) with **one defensive
42
+ patch**: `align_corners=True` → `False` on the bilinear upsamples. CPU-exact vs PyTorch
43
+ (max|diff| 0.0).
44
+
45
+ ## Minimal usage
46
+
47
+ ### Kotlin (Android, LiteRT CompiledModel GPU)
48
+
49
+ ```kotlin
50
+ val options = CompiledModel.Options(Accelerator.GPU)
51
+ val model = CompiledModel.create(context.assets, "dis.tflite", options, null)
52
+ val inBufs = model.createInputBuffers()
53
+ val outBufs = model.createOutputBuffers()
54
+
55
+ inBufs[0].writeFloat(inputNCHW) // [1,3,1024,1024] RGB, x/255 - 0.5
56
+ model.run(inBufs, outBufs)
57
+ val mask = outBufs[0].readFloat() // [1024*1024] alpha (0..1); resize -> composite
58
+ ```
59
+
60
+ ### Python (LiteRT / ai-edge-litert)
61
+
62
+ ```python
63
+ import numpy as np
64
+ from ai_edge_litert.interpreter import Interpreter
65
+
66
+ it = Interpreter(model_path="dis.tflite"); it.allocate_tensors()
67
+ inp, out = it.get_input_details(), it.get_output_details()
68
+ it.set_tensor(inp[0]["index"], x) # [1,3,1024,1024] float32, RGB, x/255 - 0.5
69
+ it.invoke()
70
+ mask = it.get_tensor(out[0]["index"])[0, 0] # [1024,1024] alpha 0..1
71
+ ```
72
+
73
+ ## Conversion
74
+
75
+ Converted with **litert-torch** (`build_dis.py`): loads the Apache-2.0 IS-Net general-use
76
+ weights and exports the main mask.
77
+
78
+ ## License
79
+
80
+ Apache-2.0 (DIS / xuebinqin). IS-Net architecture.