mlboydaisuke commited on
Commit
780c44a
·
verified ·
1 Parent(s): a4420f9

NAFNet-SIDD-width32 LiteRT fp16 (fully-GPU denoise, Pixel 8a corr 1.0)

Browse files
.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,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ library_name: LiteRT
4
+ pipeline_tag: image-to-image
5
+ tags:
6
+ - litert
7
+ - tflite
8
+ - on-device
9
+ - android
10
+ - gpu
11
+ - image-restoration
12
+ - denoising
13
+ - nafnet
14
+ base_model: megvii-research/NAFNet
15
+ ---
16
+
17
+ # NAFNet-SIDD-width32 — LiteRT (on-device image denoising, fully-GPU)
18
+
19
+ [NAFNet](https://github.com/megvii-research/NAFNet) (Nonlinear Activation Free Network, ECCV 2022) image
20
+ restoration, converted to **LiteRT** and running **fully on the `CompiledModel` GPU** (ML Drift) on Android.
21
+ This is the **SIDD-width32** variant — real-image **denoising**. NAFNet is a U-Net of NAFBlocks with **no
22
+ activation functions** (SimpleGate = channel-split multiply), so the whole network is a clean CNN on the GPU.
23
+
24
+ ![NAFNet-SIDD — noisy input | denoised (on-device LiteRT GPU)](samples/sample.png)
25
+
26
+ ## On-device (Pixel 8a, Tensor G3 — verified)
27
+
28
+ | | |
29
+ |---|---|
30
+ | nodes on GPU | **2179 / 2179** LITERT_CL (full residency) |
31
+ | inference | **~46 ms** (256×256) |
32
+ | size | 62.5 MB (fp16) |
33
+ | accuracy | device output **== PyTorch (corr 0.999999)** — re-authoring is numerically exact |
34
+
35
+ ```
36
+ image[1,3,256,256] (RGB [0,1]) →[GPU: NAFNet U-Net]→ denoised[1,3,256,256]
37
+ ```
38
+
39
+ ## How it converts (litert-torch)
40
+
41
+ Pure CNN (no activations). Three numerically-exact re-authorings, the headline being **SafeLayerNorm**:
42
+ NAFNet's residual stream grows large (|x|≈175 at the bottleneck), so the LayerNorm channel reductions
43
+ `Σ_c x` and `Σ_c (x−μ)²` (~15M) **overflow fp16 (max 65504)** on the Mali delegate (which computes in fp16
44
+ regardless of the model dtype) → a grid artifact. Doing the reductions in a down-scaled `x/S` domain (S=128)
45
+ and rescaling is exact and fp16-safe. Plus the Simplified Channel Attention `AdaptiveAvgPool2d(1)` →
46
+ `mean(3).mean(2)`, and the upsample `Conv2d(1×1)+PixelShuffle(2)` → depth-to-space `ZeroStuffConvT2d`.
47
+
48
+ Result: banned ops NONE, all tensors ≤4D, tflite-vs-torch corr **1.0**, device-vs-torch corr **1.0**.
49
+
50
+ A complete Android sample (image picker + before/after) is in the official
51
+ [google-ai-edge/litert-samples](https://github.com/google-ai-edge/litert-samples) repo under
52
+ `compiled_model_api/image_restoration` (push this `.tflite` in place of the deblur model).
53
+
54
+ ## License
55
+
56
+ [MIT](https://github.com/megvii-research/NAFNet/blob/main/LICENSE). Upstream:
57
+ [megvii-research/NAFNet](https://github.com/megvii-research/NAFNet); weights NAFNet-SIDD-width32.
nafnet_sidd_width32_fp16.tflite ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f8fbaa422411683c53e802cf7cc7cf9be0a0de00886ad4af057232e26b172a0c
3
+ size 62454048
samples/sample.png ADDED

Git LFS Details

  • SHA256: a545e89180b5d0bad5e460b5b77fe548932b16d786c8f648d003b3958c9317e3
  • Pointer size: 131 Bytes
  • Size of remote file: 303 kB