xocialize commited on
Commit
fceb0e2
Β·
verified Β·
1 Parent(s): 0835055

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +78 -0
README.md ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: mlx
3
+ license: mit
4
+ license_link: https://github.com/Fediory/HVI-CIDNet/blob/master/LICENSE
5
+ base_model: Fediory/HVI-CIDNet
6
+ pipeline_tag: image-to-image
7
+ tags:
8
+ - mlx
9
+ - low-light-enhancement
10
+ - exposure-correction
11
+ - image-enhancement
12
+ - hvi-cidnet
13
+ ---
14
+
15
+ # mlx-community/HVI-CIDNet-Generalization-fp32
16
+
17
+ [HVI-CIDNet](https://github.com/Fediory/HVI-CIDNet) low-light / exposure correction, converted to
18
+ **Apple MLX** for Apple-Silicon inference via the
19
+ [`mlx-cidnet-swift`](https://github.com/xocialize/mlx-cidnet-swift) Swift package.
20
+
21
+ Yan et al., *HVI: A New Color Space for Low-light Image Enhancement*, **CVPR 2025** β€” 1st place,
22
+ NTIRE 2025 Low-Light Enhancement Challenge. 1,975,569 parameters (7.9 MB). Underexposed image in β†’
23
+ re-exposed image at the same resolution out.
24
+
25
+ **Recommended default.** Trained for cross-dataset generalization. Does the least damage when the exposure gate mis-fires (23.37 dB on an already-correct exposure, vs 20.99 / 16.10 for the others).
26
+
27
+ ## Use with mlx-cidnet-swift
28
+
29
+ ```swift
30
+ import CIDNetMLXCore
31
+
32
+ let model = CIDNet()
33
+ try model.loadWeights(from: weightsURL) // model.safetensors from this repo
34
+ let brightened = model(imageNHWC) // NHWC RGB in [0,1]
35
+ ```
36
+
37
+ Or as an MLXEngine `imageRelight` ModelPackage (`MLXCIDNet.CIDNetRelightPackage`), which resolves
38
+ this repo via the Hub and applies the exposure gate below automatically.
39
+
40
+ ## ⚠️ Gate this model on input exposure β€” it is not safe to apply unconditionally
41
+
42
+ Every published checkpoint drives its output toward a **target mean luma regardless of input**. On
43
+ an image that is already correctly exposed the model therefore *degrades* it. Measured against a
44
+ correctly-exposed reference:
45
+
46
+ | checkpoint | applied to an already-correct exposure |
47
+ |---|---|
48
+ | Generalization | 23.37 dB |
49
+ | LOLv1-wperc | 20.99 dB |
50
+ | SICE | **16.10 dB** |
51
+
52
+ SICE's output mean stays within 0.35–0.40 across a **12Γ— input range** β€” it is an auto-exposure
53
+ normalizer, not a shadow lift.
54
+
55
+ Estimate input luma and **bypass above a threshold**; expose a strength blend for partial
56
+ application. `mlx-cidnet-swift` does both. Note also that Generalization scores **βˆ’0.52 dB β€” worse
57
+ than doing nothing** β€” at 0.70Γ— exposure, which is the *moderate* underexposure regime that
58
+ LOL-trained models are documented to handle badly.
59
+
60
+ ## Conversion
61
+
62
+ MLX **NHWC** layout: 191 tensors β†’ 81 conv + 61 depthwise transposed `(O,I,kH,kW) β†’ (O,kH,kW,I)`,
63
+ 49 passthrough. Upstream already publishes safetensors, so this is a relayout, not a format change.
64
+
65
+ `trans.density_k` is a **learned** parameter and differs per checkpoint (this one: **0.9835**; init is
66
+ 0.2). It rides in the weights β€” do not hardcode it.
67
+
68
+ ## Parity
69
+
70
+ Gated against the PyTorch oracle on the CPU stream, fp32, judged on relative error:
71
+
72
+ - **key contract** β€” 191 tensors / 1,975,569 params / 0 missing / 0 unused, strict load
73
+ - **HVI colour transform** β€” **bit-exact** (worst 6.6e-07), including the degenerate colours and
74
+ the yellow/cyan channel *ties* that decide the masking priority
75
+ - **primitives** β€” PReLU exactly 0.00e+00; the align-corners resamplers ~5e-07
76
+ - **full model** β€” cosine **1.00000000** at 64Β² / 128Β² / 256Β², and on a severely underexposed tile
77
+
78
+ Weights: MIT (Fediory/HVI-CIDNet, published first-party by the authors). Port code: MIT.