lama-onnx (LaMa big-lama, 512x512, fp16 weights)
ONNX inpainting model (LaMa, fixed 512x512) for on-device repair of scratches, folds and dust with ONNX Runtime. Used by
ReTint (com.ipsilondev.retint); also planned for Neg2Pic and LensClean.
| File | Size (bytes) | Precision |
|---|---|---|
lama_fp16.onnx |
106,183,330 | weights stored as fp16, compute and I/O float32 |
SHA-256 f45fe5e9b535a1bead6995c19f49aee458ad1167a024b911fbc7983ba6eb4b32
Provenance
- Source: https://huggingface.co/Carve/LaMa-ONNX, file
lama_fp32.onnx(208 MB, opset 17, exported with the legacytorch.onnx.exportfrom Carve-Photos/lama, original model advimman/lama big-lama), repository revisionc3c0c9e468934d62e79c329e35d82dd09ff8c444, Apache-2.0. - Conversion script:
convert_lama.pyin this repo. - Why weight-only fp16: LaMa's Fourier units are written with
Range,Cos,Sin,Einsum,MatMuland explicitCastnodes. Bothonnxconverter_common.float16andonnxruntime.transformers.float16produce graphs that ONNX Runtime refuses to load (Cast type mismatch,Rangein fp16). The script therefore stores each float32 initializer with at least 256 elements (411 tensors) as fp16 followed by aCast(to=float32)node; ORT folds these casts at session creation. The file is half the size; arithmetic stays fp32. No int8 (quality). - Packages added to the shared venv:
onnxslim,timm,scikit-image(also used by the DDColor job).
Tensors
| Name | Shape | Type | Meaning |
|---|---|---|---|
image |
[batch, 3, 512, 512] |
float32 | RGB 0-1 |
mask |
[batch, 1, 512, 512] |
float32 | 1 = repair, 0 = keep |
output |
[batch, 3, 512, 512] |
float32 | RGB in 0-255 (not 0-1) |
The output scale was measured: a mid-grey (0.5) image with an empty mask comes back as 128, and the fp32 output range on test images is 0..255. ReTint probes this at load (max > 1.5 means divide by 255).
Verification
10 masked 512x512 images (scikit-image sample photos; random scratch lines 2-5 px wide and blobs), PSNR between the fp16-weights
file and the fp32 original inside the mask, on the 0-255 scale (verify_psnr.json):
- minimum 59.96 dB, mean 71.24 dB (spec target >= 35 dB).
Desktop CPU (ORT 1.24, 4 threads), one 512x512 window: 5.6 s fp16-weights vs 4.5 s fp32; session creation about 33 s on the same machine. On-device latency is not measured yet (no device in the conversion run).
Licence
Apache-2.0, as upstream.