Models · Image restoration

LaMa (big-lama inpainting)

LaMa big-lama (Suvorov et al., Samsung AI, WACV 2022): fills the masked hole of an image (object removal) with a fast-Fourier-convolution network trained on scene photos. Apache-2.0 code and weights; the Places365 training images are for research use only (see the card).

experimental Fork of advimman/lama@786f593 · backends: portable, kernels

Checkpoint big-lama

Paper 2021 Added in 0.2.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 21.2 ms 512x512, fp16
vs the faster original 1.8× original fp16: 38.0 ms
Peak memory 219 MiB original: 239 MiB
Accuracy vs original fp32 −0.0010 portable psnr, DIV2K validation (17.8956 original)

Use it

pip install fastforks

Lean install with only what this model needs: pip install fastforks-core

from fastforks import restoration

model = restoration.load("big-lama")  # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.image
result.backend  # what ran: mode, device, dtype, kernels
fastforks bench big-lama

Times the model on this machine. load(…, mode="portable") or mode="kernels" picks a backend; usage guide.

Speed and memory

Every backend on one GPU (RTX 5060 Ti 16 GB) and the same input, the authors’ code included. Kernels runs fp16. Portable runs fp16 on CUDA.

Input: synthetic, 512x512 (the task’s standard size)

BackenddtypeTime per call (ms)vs original fp16Peak memory
allocated / reserved
Load (s)First call (s)
Original fp32fp32not measured ––––
Original fp16.half() on 1 modules, fp16 inputs; advimman/lama@786f5936b27f FFCResNetGenerator, predict.py padding / masking / paste-backfp16 38.0–239 MiB/286 MiB0.40.07
Portable fp32fp32not measured ––––
Portablefp16 26.01.5×219 MiB/242 MiB0.80.25
Kernelsfp16 21.21.8×219 MiB/284 MiB0.70.15
Portable + torch.compile 23.41.6×312 MiB/342 MiB26 (build)–
TensorRT fp16fp16 33.91.1×268 MiBenginenot comparable110 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-14 to 2026-11-16. First call, 3 warm-up, peak reset, median of 3 rounds x median of 5. Ratios divide two times of this table (same GPU, same input). Original fp16 is the authors’ own precision option, else torch.autocast. torch.compile and TensorRT: build time instead of load time. TensorRT memory (engine, not comparable) is the GPU memory the engine took, read from the driver because TensorRT allocates outside PyTorch, so it can't be compared with the PyTorch peaks of the other rows.

Other devices

DeviceBackenddtypems / callPeak memoryOutput vs referenceInput
Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-14Originalfp32334 2,096 MiB process–512x512
Portablefp16214 1,679 MiB processmatches512x512
Portablefp32241 1,797 MiB processmatches512x512
Kernelsfp16not implemented–512x512

CUDA memory is torch’s peak allocated / reserved; Apple has no such counter, so the Mac rows show the process footprint (weights, Python and torch included). “Output vs reference” compares the device’s output with the stored golden output under the card’s tolerance; – = not checked on that device. Kernels “not implemented” = no kernels for this model on that backend yet: it runs portable there.

Licence and weights

Commercial use allowed

Code
Apache-2.0 LICENSE
Weights
Apache-2.0 source
Training data

Our reading of the licences, not legal advice.

Weights

big-lama.ckpt 410 MB· inside a 381 MB archive· hosted on Hugging Face

fastforks downloads and checks these files on first use (fastforks download big-lama).

Accuracy

The test set through the authors’ code and through ours: same checkpoint, same protocol. The distance between the original’s fp32 and fp16 runs is what half precision alone costs; our runs should stay within it.

DIV2K validation

25 centre crops with two masks each, masked RGB PSNR (dB)

Rundtypepsnr ↑Δ psnr vs fp32 originalmasksms / mask
Original fp32fp3217.8956 reference 50 –
Original fp16not measured
Portable fp32fp3217.8950 −0.0006 50 –
Portablefp1617.8946 −0.0010 50 –
Kernelsnot measured

DIV2K validation HR images and the official bicubic LR images (x4 or x2, the model's scale), one pass without tiles; PSNR and SSIM (Gaussian 11 x 11, sigma 1.5) on the Y channel (BT.601) of the output rounded to uint8, `scale` px border cropped, averaged over the images. Real-ESRGAN is trained for real-world degradations, not bicubic, so its PSNR is low: the numbers compare our modes with the original, not with PSNR-oriented upscalers. Original = the authors’ code, same checkpoint and protocol. Measured on original fp32: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-17; portable fp32, portable: RTX 5060 Ti, torch 2.14.1+cu130, fastforks a7fe3731, 2026-11-17.

Closeness to the original

Beyond the test-set scores: the raw output of ours against the original’s fp32 output on the same input, pixel by pixel. CPU, float32: max |diff| <= 1e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.002 and p99 <= 0.01 (absolute error of the output image).

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.00001 not recorded
GPU default dtypes, mean |diff|≤ 0.002 0.00022
GPU default dtypes, p99 |diff|≤ 0.01 0.00403

Recorded for big-lama on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-14, with these kernels: cudnn_hacc

Details

LaMa (Suvorov et al., WACV 2022): resolution-robust large-mask inpainting with fast Fourier convolutions: an encoder of three strided convs, 18 FFC residual blocks whose global branch convolves in the frequency domain (an image-wide receptive field from the first block) and a transposed-conv decoder. big-lama (51 M parameters) is the authors' best model, trained on Places365 at 256 x 256 and works at higher resolutions. Pass `mask=` (nonzero = the region to fill); the rest of the image is kept unchanged.

Input / output
Input: one RGB image. Output: the restored (upscaled) image, model.scale x the input size, RGB in [0, 1].
What the numbers mean, and which models need the camera focal length

tile= runs large images in overlapping tiles (as ComfyUI).

Input size
any H x W >= 16, padded to a multiple of 8; tested up to 3000x4000 (5,193 MiB allocated)
Options
  • cuda_graphs=true
Outputs
image
CUDA kernels
  • cudnn_haccconvolutions with fp16 accumulation (cuDNN)
Apple (MPS)
fp32, fp16

Limitations

  • No accuracy measurement: inpainting is scored on Places / CelebA-HQ with the authors' random masks, which are not part of the evaluation data here; tiers are compared by output parity and speed only.
  • Fills the masked region from the surrounding image; it does not take a text prompt. The authors' refinement step (`refine=True`, an iterative multi-scale optimisation) is not implemented.
  • Any nonzero mask pixel is a hole (upstream binarises with `mask > 0`): anti-aliased or JPEG masks grow; threshold them first.
Full reference, generated from the repository

LaMa big-lama (Suvorov et al., Samsung AI, WACV 2022): fills the masked hole of an image (object removal) with a fast-Fourier-convolution network trained on scene photos. Apache-2.0 code and weights; the Places365 training images are for research use only (see the card).

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
big-lamasynthetic (512x512)original
portable
kernels
portable + torch.compile
TensorRT fp16
38.0
26.0
21.2
23.4
33.9
239 / 286
219 / 242
219 / 284
312 / 342
386 / 406
Details

Measured

DIV2K validation HR images and the official bicubic LR images (x4 or x2, the model's scale), one pass without tiles; PSNR and SSIM (Gaussian 11 x 11, sigma 1.5) on the Y channel (BT.601) of the output rounded to uint8, scale px border cropped, averaged over the images. Real-ESRGAN is trained for real-world degradations, not bicubic, so its PSNR is low: the numbers compare our modes with the original, not with PSNR-oriented upscalers. Original = the original code named under Details, same checkpoint and protocol.

variantdatasetoriginal fp32portableportable fp32TensorRTnote
big-lamaDIV2K validation, 25 centre crops with two masks each, masked RGB PSNR (dB)17.895617.894617.895017.8854

Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks a7fe3731, 2026-11-17.

Parity

CPU, float32: max |diff| <= 1e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.002 and p99 <= 0.01 (absolute error of the output image).

variantkernels error vs original, mean / p99GPU, torchkernels used
big-lama0.00022 / 0.00403RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400

Limitations

  • No accuracy measurement: inpainting is scored on Places / CelebA-HQ with the authors' random masks, which are not part of the evaluation data here; tiers are compared by output parity and speed only.
  • Fills the masked region from the surrounding image; it does not take a text prompt. The authors' refinement step (refine=True, an iterative multi-scale optimisation) is not implemented.
  • Any nonzero mask pixel is a hole (upstream binarises with mask > 0): anti-aliased or JPEG masks grow; threshold them first.

Example output

No example rendered for this checkpoint yet.