Image Segmentation
LiteRT
LiteRT
LiteRT
on-device
android
gpu
line-segment-detection
mlsd
wireframe
mobilenetv2
Instructions to use litert-community/M-LSD-tiny-LiteRT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/M-LSD-tiny-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
M-LSD-tiny LiteRT fp16 (fully-GPU, Pixel 8a corr 0.997, 2ms, 1.4MB)
Browse files- .gitattributes +1 -0
- README.md +49 -0
- mlsd_fp16.tflite +3 -0
- samples/sample.png +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
samples/sample.png filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
library_name: LiteRT
|
| 4 |
+
pipeline_tag: image-segmentation
|
| 5 |
+
tags: [litert, tflite, on-device, android, gpu, line-segment-detection, mlsd, wireframe, mobilenetv2]
|
| 6 |
+
base_model: navervision/mlsd
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
# M-LSD-tiny β LiteRT (on-device line segment detection, fully-GPU)
|
| 10 |
+
|
| 11 |
+
[M-LSD](https://github.com/navervision/mlsd) (NAVER, AAAI 2022) light-weight real-time **line segment
|
| 12 |
+
detection**, converted to **LiteRT** and running **fully on the `CompiledModel` GPU** (ML Drift) on Android.
|
| 13 |
+
Detects straight line segments β building edges, document borders, wireframes, room layout. The **tiny**
|
| 14 |
+
variant (MobileNetV2 backbone, 0.62M params) is **1.4 MB** in fp16.
|
| 15 |
+
|
| 16 |
+

|
| 17 |
+
|
| 18 |
+
## On-device (Pixel 8a, Tensor G3 β verified)
|
| 19 |
+
|
| 20 |
+
| | |
|
| 21 |
+
|---|---|
|
| 22 |
+
| nodes on GPU | **99 / 99** LITERT_CL (full residency) |
|
| 23 |
+
| inference | **~2 ms** (512Γ512) |
|
| 24 |
+
| size | **1.4 MB** (fp16) |
|
| 25 |
+
| accuracy | device-vs-PyTorch corr **0.997** (127 vs 128 lines decoded) |
|
| 26 |
+
|
| 27 |
+
```
|
| 28 |
+
image[1,4,512,512] (RGB + ones channel, scaled to [-1,1]) β[GPU: MobileNetV2 U-Net]β tpMap[1,9,256,256]
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
The output is a "TP map": channel 0 = line-center heatmap, channels 1β4 = start/end displacement. The decode
|
| 32 |
+
(sigmoid + 3Γ3 NMS over centers, displacement β endpoints, Γ2) runs on the host.
|
| 33 |
+
|
| 34 |
+
## How it converts (litert-torch)
|
| 35 |
+
|
| 36 |
+
Pure CNN encoder-decoder. A single re-authoring: the decoder's `F.interpolate(bilinear, align_corners=True)`
|
| 37 |
+
β **`align_corners=False`** (the Mali delegate bans `align_corners=True` + half-pixel). MobileNetV2 has no
|
| 38 |
+
max-pool (strided convs β no `PADV2`), and the upsample is `RESIZE_BILINEAR`, not a transposed conv β fully
|
| 39 |
+
GPU-clean. Result: banned ops NONE, all tensors β€4D, tflite-vs-torch corr **1.0**, device-vs-torch corr **0.997**.
|
| 40 |
+
|
| 41 |
+
## Preprocessing & decode
|
| 42 |
+
|
| 43 |
+
Resize to 512Γ512, append a 4th channel of ones, scale `(x/127.5) - 1`, NCHW. Decode: sigmoid the center map,
|
| 44 |
+
3Γ3 max NMS, threshold (0.10), displacement β endpoints, filter by length, Γ2 to 512-space.
|
| 45 |
+
|
| 46 |
+
## License
|
| 47 |
+
|
| 48 |
+
[Apache-2.0](https://github.com/navervision/mlsd/blob/main/LICENSE). Upstream:
|
| 49 |
+
[navervision/mlsd](https://github.com/navervision/mlsd); PyTorch port [lhwcv/mlsd_pytorch](https://github.com/lhwcv/mlsd_pytorch).
|
mlsd_fp16.tflite
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e5da930ae4a0dacd7725b0126a1d1481eaac3b3f537000f7f981461d1b1305f2
|
| 3 |
+
size 1389952
|
samples/sample.png
ADDED
|
Git LFS Details
|