big-lama, dynamic-shape ONNX export for greycard

LaMa (Suvorov et al., "Resolution-robust Large Mask Inpainting with Fourier Convolutions", WACV 2022), the big-lama checkpoint from advimman/lama, exported to ONNX for greycard's eraser. The weights are untouched.

  • File: big-lama-dynamic-fp32.onnx, fp32, opset 21.
  • Inputs: image (1, 3, H, W), RGB in 0 to 1; mask (1, 1, H, W), 1 inside the hole, 0 outside. H and W are any multiples of 8 from 32 up.
  • Output: output (1, 3, H, W) in 0 to 1: the model's answer inside the hole and the image outside, as LaMa's own forward pass composites it.

How it was made

lama_export.py builds the generator from big-lama/config.yaml, loads big-lama/models/best.ckpt, and exports it with PyTorch's dynamo exporter (torch 2.14, onnx 1.23) with a dynamic height and width. The Fourier units' torch.fft.rfftn and irfftn are written as the same transforms by real matrix products, the matrices made from the tensor's size inside the graph, so every op runs on ONNX Runtime's WebGPU provider. Exported as is, the ONNX DFT nodes fail on a shape mismatch in ONNX Runtime 1.30 (the Python package we checked them with; greycard runs 1.28, where we did not try them).

Checked against the original: on a 512 picture the output inside the hole is within 2e-5 of Carve's fixed-size export of the same checkpoint; against PyTorch with torch.fft at 512, 1024, and 2048 it is within 1.2e-4.

A dynamic shape is not a license to fill any hole at full size: as the original does, the answer degrades once a hole pixel lies more than about 64 model pixels from a known one (a ghost of what was removed, then a dark smear). greycard fills such a hole at the scale that brings it to that depth.

Opset 21 is the highest at which the graph runs whole on ONNX Runtime 1.28's WebGPU provider; at 22 and 23 some ops fall back to the CPU.

License

Apache-2.0, as the original: see LICENSE beside the model, copied from advimman/lama, Copyright 2021 Samsung Research. This export is a modified form of that work, changed as described above.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support