Inpainting (MLX)
Collection
Apple-MLX fp16 inpainting / object-removal models (LaMa Apache-2.0 + MI-GAN MIT). Loaded by mlx-lama-swift. • 4 items • Updated • 1
How to use mlx-community/LaMa-bf16 with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] huggingface-cli download --local-dir LaMa-bf16 mlx-community/LaMa-bf16
Big-LaMa FFC inpainting (quality tier), converted to Apple MLX (bf16) for the
mlx-lama-swift Swift package (MLXEngine imageInpaint
/ Forge Erase). From-scratch MLX-Swift port of advimman/lama;
parity-locked vs PyTorch (predicted max_abs 3.2e-5 fp32).
bf16, not fp16: LaMa's Fast Fourier Convolution produces high-magnitude bottleneck activations (~1e3); fp16 weight rounding collapses the model (mean err 0.55), while bf16's wider exponent range preserves it (mean 4e-3, visually identical to fp32). Use bf16 or fp32 — not fp16.
import LaMa
let inpainter = try LaMaInpainter.fromPretrained(weightsPath, dtype: .bfloat16)
let filled = inpainter(sourceCGImage, mask: maskCGImage) // white mask = remove
Weights: Apache-2.0 (advimman/lama). Port: MIT.
Quantized