---
title: LaMa-fp32
canonical_url: "https://www.modelscope.cn/models/mlx-community/LaMa-fp32"
md_url: "https://www.modelscope.cn/models/mlx-community/LaMa-fp32.md"
repository: mlx-community/LaMa-fp32
last_updated: 2026-10-10
license: apache-2.0
pipeline_tag: image-to-image
tasks:
  - image-to-image
base_model:
  - advimman/lama
base_model_relation: finetune
library_name:
  - mlx
  - safetensors
  - pytorch
frameworks:
  - pytorch
downloads: 14
stars: 0
tags:
  - mlx
  - inpainting
  - object-removal
---

# LaMa-fp32

> LaMa-fp32 - mlx-community 在 ModelScope 开源的模型。mlx-community/LaMa-fp32

mlx-community/LaMa-fp32 是 ModelScope 魔搭社区上的image-to-image模型，采用 apache-2.0 许可，基于 advimman/lama 构建。

- **Repository**: mlx-community/LaMa-fp32
- **License**: apache-2.0
- **Tasks**: image-to-image
- **Base model**: advimman/lama
- **Tags**: mlx, inpainting, object-removal
- **Downloads**: 14
- **Stars**: 0
- **Last updated**: 2026-10-10

Source: https://www.modelscope.cn/models/mlx-community/LaMa-fp32

---

# 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`](https://github.com/xocialize/mlx-lama-swift) Swift package (the MLXEngine
`imageInpaint` ModelPackage). From-scratch MLX-Swift architecture port of
[advimman/lama](https://github.com/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

```swift
// 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.
