Instructions to use litert-community/CPGA-Net-LowLight-LiteRT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/CPGA-Net-LowLight-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
Measured on device (edge-compat): Galaxy S26 · LiteRT 2.2.0 · GPU (ML Drift) · 14.9 ms p50 (2026-08-25); Galaxy S26 · LiteRT 2.2.0 · NPU (QNN/HTP) · 4.62 ms p50 (2026-08-25); Raspberry Pi 5 · LiteRT 2.2.0.dev20260804 · CPU/XNNPACK, 4 threads · 78.8 ms p50 (2026-08-31); browser · Chromium 151 on M4 Max · LiteRT.js 2.5.3 · WebGPU · 17.3 ms p50 · output matches CPU (2026-08-11). Record: https://github.com/john-rocky/edge-compat/blob/main/cards/cpga-net-lowlight/CARD.md
CPGA-Net — LiteRT (on-device low-light enhancement, fully-GPU)
CPGA-Net (Shyandram, IJPRAI), low-light image enhancement
(brighten dark photos) via Channel Prior + Gamma Correction, converted to LiteRT and running fully on the
CompiledModel GPU (ML Drift) on Android. 0.025 M params / 0.1 MB fp16 — the smallest model in the
LiteRT-Models zoo.
On-device (Pixel 8a, Tensor G3 — verified)
| nodes on GPU | 135 / 135 LITERT_CL (full residency) |
| inference | ~2 ms (256×256) |
| size | 0.1 MB (fp16) |
| accuracy | device-vs-PyTorch corr 0.99999, no NaN |
image[1,3,256,256] (RGB [0,1]) →[GPU: CPGA-Net]→ enhanced[1,3,256,256] ([0,1])
Minimal usage
Android (Kotlin, CompiledModel GPU)
val model = CompiledModel.create(context.assets, "cpga_fp16.tflite",
CompiledModel.Options(Accelerator.GPU), null)
val inputs = model.createInputBuffers()
val outputs = model.createOutputBuffers()
inputs[0].writeFloat(chw) // [1,3,256,256] RGB in [0,1], NCHW
model.run(inputs, outputs)
val enhanced = outputs[0].readFloat() // [1,3,256,256], [0,1]
Python (desktop verification)
import numpy as np
from PIL import Image
from ai_edge_litert.interpreter import Interpreter
img = Image.open("dark.jpg").convert("RGB")
w, h = img.size; s = min(w, h)
img = img.crop(((w-s)//2, (h-s)//2, (w+s)//2, (h+s)//2)).resize((256, 256))
x = (np.asarray(img, np.float32) / 255.0).transpose(2, 0, 1)[None] # [1,3,256,256]
it = Interpreter(model_path="cpga_fp16.tflite"); it.allocate_tensors()
it.set_tensor(it.get_input_details()[0]["index"], x); it.invoke()
y = it.get_tensor(it.get_output_details()[0]["index"])[0] # [3,256,256], [0,1]
Image.fromarray((y.transpose(1, 2, 0).clip(0, 1) * 255).astype(np.uint8)).save("enhanced.png")
How it converts (litert-torch) — three numerically-exact fixes
- Gamma correction
x^γ→exp(γ·log x)—torch.powlowers to the bannedPOW; the identityx^γ = exp(γ·log x)is exact (base clamped to [1e-9,1]) and uses nativeEXP/LOG. - CBAM / gamma global pools →
mean(3).mean(2)andF.max_pool2d(x, (H,W)). - The dark/bright channel prior (
max/minover RGB) stays asREDUCE_MAX/REDUCE_MIN.
Banned ops NONE, ≤4D, tflite-vs-torch corr 1.0, device-vs-torch corr 0.99999. Guided-filter disabled.
Preprocessing
Center-crop, resize 256×256, RGB scaled to [0,1], NCHW.
Performance
Measured on a Pixel 8a (Tensor G3, Android 16) with the standard TFLite benchmark_model tool — 10 warm-up runs then 50 timed runs, reported as the tool's mean.
| Runtime | Backend | Graph on GPU | Latency |
|---|---|---|---|
TFLite benchmark_model (TfLiteGpuDelegateV2) — cpga_fp16.tflite |
GPU (OpenCL) | — | did not run |
TFLite benchmark_model (TfLiteGpuDelegateV2) — cpga_fp16.tflite |
GPU (OpenCL) | 135 / 135 | 42.5 ms |
TFLite benchmark_model — cpga_fp16.tflite |
CPU (XNNPACK, 4 threads) | — | XNNPACK declined the graph |
Any on-device figure recorded when this model shipped came from a different runtime. It was taken through LiteRT's own CompiledModel accelerator (logcat reports it as LITERT_CL), which is the path the Kotlin sample app and the LiteRT API use, and it appears elsewhere on this card. The rows above are the classic TFLite OpenCL delegate, measured with a tool anyone can download and re-run. The two are not comparable, so read the rows above as a reproducible floor rather than as this model's speed on LiteRT.
XNNPACK declines these fp16 graphs — it reports failed to delegate DEPTHWISE_CONV_2D and then fails to allocate tensors — so there is no usable CPU number. Disabling XNNPACK falls back to reference kernels, which measured about 20× slower than the GPU on models of this size and would not represent CPU inference anyone would ship.
Snapdragon NPU (Hexagon)
The NPU is 3.23x faster than the GPU (4.62 ms against 14.94 ms) and loads 8.62x faster (103 ms against 886 ms).
| backend | compiled | inference (median / min) | load |
|---|---|---|---|
| NPU (Hexagon v81) | on-device JIT | 4.62 ms / 4.53 ms | 103 ms |
| GPU (Adreno) | — | 14.94 ms / 14.75 ms | 886 ms |
Measured on a Samsung Galaxy S26 (Snapdragon 8 Elite Gen 5 / SM8850, Hexagon v81, Android 16) with LiteRT CompiledModel 2.2.0, one accelerator per process, 5 warm-up runs then N=50 timed runs, median reported. Every run held thermal status NONE throughout. Headroom 0.52–0.53, where 1.0 is the throttling threshold.
The NPU rows ran the published file unchanged. LiteRT compiled it for the Hexagon on the device at first load. That first compile took 2.2 s here. The load column above is the cached load every later run pays. Recipe and the runtime libraries it needs: NPU guide.
GPU wiring: GPU guide.
Raspberry Pi 5 (CPU)
Measured on a Raspberry Pi 5 Model B Rev 1.1 (8 GB, Raspberry Pi OS 64-bit) with the LiteRT benchmark_model tool from litert-cli-nightly 0.2.0.dev20260805: CPU inference (XNNPACK, 4 threads), 3 invocations per file of 10 warm-up plus 50 timed runs (the tool caps a phase at 150 s, so very slow graphs run fewer — the Runs column is the actual timed total). The latency is the median across invocations; the spread is the min–max over all timed runs. No thermal throttling occurred during these runs (vcgencmd get_throttled stayed 0x0).
| File | Inference (median) | Spread (min–max) | Runs | Peak memory |
|---|---|---|---|---|
cpga_fp16.tflite |
78.8 ms | 76.6–80.5 ms | 150 | 168 MB |
License
MIT. Upstream: Shyandram/CPGA-Net-Pytorch.
- Downloads last month
- 49
