mlx-community/LaMa-fp32

Big-LaMa FFC inpainting (quality tier). Large masks + structured backgrounds.

Converted to Apple MLX (fp32) for Apple-Silicon inference via the mlx-lama-swift Swift package (the MLXEngine imageInpaint ModelPackage). From-scratch MLX-Swift architecture port of advimman/lama, parity-locked against the PyTorch oracle on the CPU stream.

Precision: fp32 only

LaMa does not survive reduced-precision weights. bf16 rounds each weight by up to ~0.4%, and the error compounds through 18 residual FFC blocks whose activations reach ~1e4. The earlier mlx-community/LaMa-bf16 cast large fills in colour photos pink: max_abs 7.5e-2 against PyTorch on a colour fixture, where this fp32 file reads 5.0e-6. fp16 collapses the FFC outright. Casting bf16 weights up to fp32 at load does not help, because the file has already lost the precision. Load these weights fp32 and keep them fp32.

Parity: lama-smoke predicted max_abs 5.0e-6 against the PyTorch oracle on a colour 512² fixture with a 29% hole (CPU). The oracle matches the original advimman/lama output within 1 level. The GPU erase path matches PyTorch within 1 level in every hole pixel.

Use

// Package.swift → .package(url: "https://github.com/xocialize/mlx-lama-swift", from: "0.3.1")
import LaMa   // or MIGAN
let inpainter = try LaMaInpainter.fromPretrained(weightsPath, dtype: .float32)
let filled: CGImage = inpainter(sourceCGImage, mask: maskCGImage)  // white mask = remove

Input: image + mask (white = region to remove). Output: filled image at source resolution. Weights license: apache-2.0. Port code: MIT.

Downloads last month

-

Downloads are not tracked for this model. How to track
Safetensors
Model size
51.1M params
Tensor type
F32
·
MLX
Hardware compatibility
Log In to add your hardware

Quantized

Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including mlx-community/LaMa-fp32