LaMa ("Resolution-robust Large Mask Inpainting with Fourier Convolutions", Suvorov et al., WACV 2022) as a single fp32 ONNX graph that runs on onnxruntime-web's WebGPU execution provider. It is used by the on-device AI eraser of the ToolsMonk Photo Editor and Background Remover.
The published LaMa ONNX exports run in the browser on WASM only. On WebGPU (onnxruntime-web 1.30) every run fails inside the Fourier unit ("Failed to run JSEP kernel"). This file is the same model with three numerically equivalent graph rewrites:
Einsum (ij,jk->ik, 216 nodes) rewritten as MatMul;Slice (72 nodes) rewritten as Gather with constant reversed indices.Maximum output difference against the source on a 512x512 test input: 0.00026 on the 0..255 scale. Measured in Chrome: ~1.7-2.2 s per 512x512 inpaint on WebGPU, against ~30 s on single-threaded WASM.
image: float32 [1, 3, 512, 512], RGB in 0..1mask: float32 [1, 1, 512, 512], 1 = area to fill, 0 = keepoutput: float32 [1, 3, 512, 512], RGB in 0..255lama_fp32.onnx, Apache-2.0
(sha256 1faef5301d78db7dda502fe59966957ec4b79dd64e16f03ed96913c7a4eb68d6).build-lama-webgpu.py in this repository (requires onnx, onnxruntime, numpy).This derivative is distributed under the same Apache-2.0 licence. The rewrites change the graph's structure, not its weights.