Instructions to use mlboydaisuke/zero-dce-litert with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use mlboydaisuke/zero-dce-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
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
library_name: litert
|
| 4 |
+
pipeline_tag: image-to-image
|
| 5 |
+
base_model: sayakpaul/zero-dce
|
| 6 |
+
tags:
|
| 7 |
+
- litert
|
| 8 |
+
- tflite
|
| 9 |
+
- on-device
|
| 10 |
+
- android
|
| 11 |
+
- low-light-enhancement
|
| 12 |
+
- image-enhancement
|
| 13 |
+
- zero-dce
|
| 14 |
+
- gpu
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# Zero-DCE — LiteRT (TFLite) GPU, FP16
|
| 18 |
+
|
| 19 |
+
On-device [LiteRT](https://ai.google.dev/edge/litert) (`.tflite`) conversion of
|
| 20 |
+
**[Zero-DCE](https://github.com/Li-Chongyi/Zero-DCE)** (Zero-Reference Deep Curve
|
| 21 |
+
Estimation) for **low-light image enhancement**. The DCE-Net is a tiny 7-layer CNN
|
| 22 |
+
that estimates pixel-wise tone curves; the curves are applied iteratively (8×) to
|
| 23 |
+
brighten the image. The whole pipeline (curve estimation **and** the iterative
|
| 24 |
+
application) is baked into the graph, so the model takes a dark image and returns the
|
| 25 |
+
enhanced image directly.
|
| 26 |
+
|
| 27 |
+
The model runs **fully on the LiteRT `CompiledModel` GPU accelerator** (ML Drift):
|
| 28 |
+
every op is GPU-native, no CPU fallback, no Flex/Custom ops. Converted with
|
| 29 |
+
[`litert-torch`](https://github.com/google-ai-edge/ai-edge-torch) **with no patches**.
|
| 30 |
+
|
| 31 |
+
## Files
|
| 32 |
+
|
| 33 |
+
| File | Precision | Size |
|
| 34 |
+
|------|-----------|------|
|
| 35 |
+
| `zerodce_512_fp16.tflite` | fp16 weights | ~0.18 MB |
|
| 36 |
+
| `zerodce_512.tflite` | fp32 | ~0.34 MB |
|
| 37 |
+
|
| 38 |
+
## I/O
|
| 39 |
+
|
| 40 |
+
- **Input**: `[1, 512, 512, 3]` float32, **NHWC**, RGB, range **`[0, 1]`** (just divide
|
| 41 |
+
by 255 — no mean/std normalization).
|
| 42 |
+
- **Output**: `[1, 512, 512, 3]` float32, **NHWC**, RGB, range `[0, 1]` — the enhanced
|
| 43 |
+
image. Multiply by 255 to display.
|
| 44 |
+
|
| 45 |
+
## Ops
|
| 46 |
+
|
| 47 |
+
The graph lowers entirely to GPU-clean builtins — the iterative curve application
|
| 48 |
+
`x = x + r·(x² − x)` is written as `x*x` so it becomes `MUL`, not `POW`:
|
| 49 |
+
|
| 50 |
+
```
|
| 51 |
+
CONV_2D x7, MUL x16, SUB x8, ADD x8, SLICE x8, CONCATENATION x3, TANH x1
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
No `GATHER_ND`, no Flex/Custom, no >4D reshapes.
|
| 55 |
+
|
| 56 |
+
## Fidelity
|
| 57 |
+
|
| 58 |
+
- Converted fp32 vs original PyTorch: **corr 1.0000**, max|diff| ~2e-5.
|
| 59 |
+
- fp16 vs fp32: **corr 1.0000**, max|diff| ~3e-5.
|
| 60 |
+
|
| 61 |
+
## On-device (Pixel 8a, verified)
|
| 62 |
+
|
| 63 |
+
The fp16 model compiles to **58 / 58 nodes on the LiteRT GPU delegate (LITERT_CL)** —
|
| 64 |
+
full GPU residency, no CPU fallback.
|
| 65 |
+
|
| 66 |
+
## Usage (Android, LiteRT CompiledModel)
|
| 67 |
+
|
| 68 |
+
```kotlin
|
| 69 |
+
val model = CompiledModel.create(
|
| 70 |
+
context.assets, "zerodce_512_fp16.tflite",
|
| 71 |
+
CompiledModel.Options(Accelerator.GPU), null
|
| 72 |
+
)
|
| 73 |
+
val inputs = model.createInputBuffers()
|
| 74 |
+
val outputs = model.createOutputBuffers()
|
| 75 |
+
inputs[0].writeFloat(rgbFloats01) // [1,512,512,3] interleaved RGB in [0,1]
|
| 76 |
+
model.run(inputs, outputs)
|
| 77 |
+
val enhanced = outputs[0].readFloat() // [1,512,512,3] in [0,1]
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
A complete Android sample (live camera + gallery low-light enhancement) is available in
|
| 81 |
+
[google-ai-edge/litert-samples](https://github.com/google-ai-edge/litert-samples).
|
| 82 |
+
|
| 83 |
+
## License & attribution
|
| 84 |
+
|
| 85 |
+
- License: **Apache-2.0** (© the Zero-DCE authors,
|
| 86 |
+
[Li-Chongyi/Zero-DCE](https://github.com/Li-Chongyi/Zero-DCE)). Original work:
|
| 87 |
+
Guo et al., *"Zero-Reference Deep Curve Estimation for Low-Light Image Enhancement"*,
|
| 88 |
+
CVPR 2020. This is a format conversion of the official weights (no architectural
|
| 89 |
+
changes); all credit to the original authors.
|