비주얼 AI 가이드

LaMa 해상도-강력한 인페인팅

LaMa (Large Mask Inpainting) is an image inpainting model from Samsung AI researchers, presented at WACV 2022, that fills large holes in photos by using Fourier convolutions to see the whole image at once.

이 가이드를 들어보세요AI 내레이션 · ~8 min

이 페이지에서9분 읽기
  1. 개요
  2. 주요 시사점
  3. 심층 분석
  4. Removing an object from a photo with LaMa
  5. 실제 구현
  6. LaMa 해상도의 미래 - 강력한 인페인팅
  7. 실천에 옮기기
  8. 출처 및 추가 자료
  9. 계속 탐색하세요
  10. 자주 묻는 질문

개요

Trained only on 256 by 256 crops, it works on much larger images, and its small size and open code made it the default object-removal engine in many free tools.

주요 시사점

  1. LaMa is a large-mask image inpainting model from Samsung AI researchers, posted in September 2021 and published at WACV 2022.
  2. Fast Fourier convolutions give LaMa an image-wide receptive field from its first layers, which helps fill large holes and repeating patterns.
  3. The base LaMa-Fourier has 27 million parameters, about a quarter the size of CoModGAN, yet scored better FID in most of the paper's tests.
  4. LaMa trains on 256 by 256 crops but works at much higher resolutions, which the official README puts at up to about 2K.
  5. LaMa's fills are plausible inventions, not recovered pixels, and the model struggles with periodic patterns under strong perspective.

심층 분석

Image inpainting is the task of filling in a missing or masked region of a photo so that the result looks natural. The user supplies an image and a mask, a black-and-white image marking which pixels to replace, and the model paints new content into the hole. Uses range from removing a tourist from a landmark shot to repairing scratches. The fill is a plausible guess, not a recovery of what was really there: the original pixels are gone, and the model invents content consistent with its surroundings. LaMa, short for Large Mask Inpainting, is a 2021 model designed for the hardest version of this task, where the hole is large and the image is high resolution.

The paper, by Roman Suvorov, Elizaveta Logacheva, Victor Lempitsky and colleagues at Samsung AI Center Moscow, Samsung Research and the Skolkovo Institute of Science and Technology, was posted to arXiv on September 15, 2021 and published at WACV 2022. Its diagnosis was that earlier inpainting networks lacked an effective receptive field, the area of the input that can influence each output pixel. An ordinary convolution looks only at a small neighborhood, such as 3 by 3 pixels, so a network needs many layers before a pixel in the middle of a large hole can see anything outside it. When the hole is bigger than the receptive field, the network has no context and produces blur or repeated smudges.

LaMa's answer has three parts. The first is the fast Fourier convolution (FFC), introduced by Lu Chi, Borui Jiang and Yadong Mu at NeurIPS 2020. An FFC splits a layer's channels into two branches. The local branch uses ordinary convolutions. The global branch applies a fast Fourier transform, which re-expresses the whole feature map as a sum of waves at different frequencies, processes those frequencies with a small learned layer, and transforms back. Because every frequency component depends on every pixel, the global branch gives each layer an image-wide receptive field from the very first block. This also suits repeating patterns such as brick walls, fences and windows, which show up as strong peaks at particular frequencies.

The second part is the loss, the measure of error that training minimizes. LaMa combines an adversarial loss, in which a separate discriminator network tries to tell filled patches from real ones, with a high receptive field perceptual loss. A perceptual loss compares images through the features of another pretrained network rather than pixel by pixel, so it rewards plausible structure instead of an exact copy of the original. LaMa computes it with a ResNet-50 segmentation network that uses dilated convolutions, which spread out their kernel taps to cover large areas, so the loss itself judges global layout. The third part is training data: masks drawn as wide polygonal strokes or large boxes of random shape, chosen with equal probability, so the model learns to fill big holes rather than thin scratches.

The results justified the design. The base LaMa-Fourier model has 27 million parameters, against 109 million for CoModGAN and 85 million for MADF, the two closest competitors. On the Places scene dataset with wide masks it scored a Fréchet Inception Distance (FID, a measure of how realistic a set of images looks, lower is better) of 2.21 against 5.94 for AOT GAN and 3.76 for MADF, though CoModGAN's 1.82 was better on that one test. On segmentation-shaped masks LaMa scored 5.35 against 6.40 for CoModGAN, and on CelebA-HQ faces with wide masks 6.96 against 24.4. The authors trained a larger Big LaMa with 18 residual blocks and 51 million parameters on 4.5 million Places-Challenge images, using eight NVIDIA V100 GPUs for about 240 hours.

The resolution-robust part of the name refers to generalization. LaMa was trained on 256 by 256 crops but evaluated at up to 1536 by 1536, and the paper found that FFC models degrade much less as resolution grows than models with regular or dilated convolutions. The official README says LaMa generalizes to resolutions up to about 2K. A 2022 CVPR workshop paper by Prakhar Kulshreshtha, Brian Pugh and Salma Jiddi of Geomagical Labs pushed further: it optimizes the network's intermediate features at inference time with a multiscale consistency loss, so coarse, coherent structure from a downscaled pass guides fine detail at full resolution. That refinement was merged into the official code.

Compared with diffusion-based inpainting, such as Stable Diffusion inpainting checkpoints, LaMa is a single forward pass with no text prompt. That makes it fast and predictable for removal, where the goal is to make something disappear into the background. Diffusion models can add new content described in a text prompt, like replacing a bench with a fountain, at the cost of many denoising steps per image. IOPaint reflects this split, using LaMa for erasing and diffusion models such as PowerPaint and SDXL inpainting for replacement and outpainting.

LaMa has clear limits. Its authors note that it usually struggles when strong perspective distorts periodic structures, such as a tiled floor receding into the distance, which is common in internet photos unlike its training data. The Fourier version is about 20% slower than a regular-convolution version of the same model. And because it hallucinates plausible content, it should never be used to claim what a hidden area actually contained, for instance in evidence or documentation.

Running LaMa is inexpensive. The checkpoint is small, inference is one network pass, and IOPaint runs it on a CPU, though a GPU is faster. Training a model from scratch is another matter, as Big LaMa's roughly 1,900 GPU-hours show, and the Places-Challenge training images alone take about 476 GB. The official repository provides pretrained models, Docker scripts for CPU and CUDA, and a mask generator for evaluation.

04실제 사례

Removing an object from a photo with LaMa

  1. Pick a photo with an unwanted object against a fairly uniform background, such as a sign on a grassy field.

  2. Create a mask the same size as the photo, painting the object and a small margin around it white and everything else black.

  3. Install IOPaint with pip and start it with the LaMa model on CPU, then open the local web page it serves.

  4. Load the photo, brush over the object, and run the fill; alternatively place image.png and image_mask001.png in a folder and run the official predict script with big-lama.

  5. Zoom in on the filled area at full resolution and look for blur, repeated patches or broken straight lines.

  6. Repeat with a photo where the object sits in front of a tiled floor in perspective, and compare the quality of the two fills.

그것이 보여주는 것

A cleaned photo and a direct comparison of an easy and a hard case. The plain background should fill convincingly, while the perspective tiles will likely show bent or misaligned lines, the failure mode the paper's authors describe.

실제 구현

Erasing unwanted people, objects, defects or watermarks in IOPaint, an Apache-2.0 open-source tool from Sanster, the developer of lama-cleaner, which uses LaMa for removal and runs on CPU, NVIDIA GPU or Apple Silicon.

Batch inpainting a folder of photos with the official advimman/lama repository by saving each mask as image1_mask001.png next to image1.png and running bin/predict.py with the big-lama checkpoint.

Improving high-resolution results with the feature refinement method from Geomagical Labs, which optimizes LaMa's internal features at inference time and is enabled in the official code with refine=True.

Running LaMa on Apple devices through CoreMLaMa, a community conversion to Apple's Core ML format listed in the official repository's README.

Benchmarking a new inpainting model against LaMa on Places and CelebA-HQ with FID and LPIPS, the datasets and metrics used in the original paper.

LaMa 해상도의 미래 - 강력한 인페인팅

The LaMa authors left one question explicitly open in their 2022 paper: whether Fourier convolutions can handle deformed periodic signals, such as patterns seen in strong perspective, where the model usually struggles. High-resolution coherence was a second thread, addressed in 2022 by feature refinement at inference time, which trades extra computation per image for better structure without retraining. The broader direction of inpainting has since moved toward diffusion models that can add content guided by text, and tools such as IOPaint now pair LaMa for removal with diffusion models such as PowerPaint, BrushNet and SDXL inpainting for replacement and outpainting. LaMa's lasting role is as a light, fast removal model and a standard baseline on Places and CelebA-HQ. Open problems for the field include filling holes that hide complex objects or text, measuring realism in ways that match human judgment better than FID, and labeling edited images so that plausible fills are not mistaken for real content.

실천에 옮기기

왜 중요한가요?

  • 속도와 규모. Visual AI는 대규모 검사, 감지 및 태그 지정 작업을 자동화할 수 있습니다.
  • 빌드 선택. 크리에이티브 팀은 수동 수정 횟수를 줄여 컨셉의 프로토타입을 더 빠르게 제작할 수 있습니다.
  • 팀과 워크플로우. 이전에는 처리하기 어려웠던 이미지 및 비디오 신호를 작업에 사용할 수 있습니다.

조심하세요

  • 출처가 불분명할 경우 이미지 권리 및 동의는 법적 위험이 될 수 있습니다.
  • 모델 성능은 조명, 인구통계, 환경에 따라 달라질 수 있습니다.
  • 신뢰도 임계값을 모니터링하지 않으면 거짓양성이 발견되지 않을 수 있습니다.

다음 단계

  1. 정밀도, 재현율, 오류 비용에 대한 허용 기준을 정의합니다.
  2. 실제 생산 조건과 일치하는 데이터로 테스트합니다.
  3. 신뢰도가 낮거나 영향력이 큰 예측에 대해 인적 검토를 추가합니다.
  4. 모델 드리프트를 추적하고 카메라 또는 데이터 세트가 변경된 후 재검증합니다.

출처 및 추가 자료

  1. arXiv (WACV 2022)Resolution-robust Large Mask Inpainting with Fourier Convolutions
  2. GitHubadvimman/lama: LaMa Image Inpainting
  3. NeurIPS 2020Fast Fourier Convolution
  4. arXiv (CVPR 2022 Workshop)Feature Refinement to Improve High Resolution Image Inpainting
  5. GitHubSanster/IOPaint

계속 탐색하세요

무료 뉴스레터

일일 AI 브리핑 받기

매주 평일 아침마다 3개의 검증된 AI 스토리를 일반 영어로 작성합니다. 무료이며, 광고 없음.

매주 평일마다 한 번 이메일을 받습니다. 한 번 클릭으로 구독 해지. 주소를 판매하거나 공유하지 않습니다.

자신을 테스트해 보세요

Take the LaMa Resolution-Robust Inpainting quiz

모든 답변에 즉각적인 피드백과, 과정을 통과하면 검증 가능한 ID가 있는 공유 가능한 인증서를 제공합니다.

퀴즈 시작

무료 AI 교육을 지원합니다. AI Understanding는 501(c)(3) 비영리 단체입니다 — 광고 없음, 유료 장벽 없음, 영원히. 기부하기

자주 묻는 질문

LaMa 해상도-강력한 인페인팅이란 무엇입니까?

LaMa (Large Mask Inpainting) is an image inpainting model from Samsung AI researchers, presented at WACV 2022, that fills large holes in photos by using Fourier convolutions to see the whole image at once. Trained only on 256 by 256 crops, it works on much larger images, and its small size and open code made it the default object-removal engine in many free tools.

LaMa에게 이미지에 대한 전체적인 시각을 제공하는 대표적인 건축 구성 요소는 무엇입니까?

LaMa는 주파수 영역에서 부분적으로 작동하여 단일 레이어에서 전역 수용 필드를 제공하는 FFC(Fast Fourier Convolution)를 사용합니다.

LaMa가 이전의 많은 인페인팅 모델보다 대형 마스크를 더 잘 처리하는 이유는 무엇입니까?

FFC는 전체 이미지를 한 번에 보기 때문에 LaMa는 매우 큰 누락 영역에서도 텍스처와 형상을 일관되게 계속 이어갈 수 있습니다.

What resolution behavior did the LaMa paper report?

The authors report that LaMa generalized to higher-than-training resolutions in their experiments; performance is still dependent on the image and mask.

LaMa는 주파수 영역 처리 덕분에 어떤 종류의 텍스처를 특히 잘 처리합니까?

주파수 영역 컨볼루션은 주기적인 패턴에 매우 적합하므로 LaMa는 벽돌 벽과 타일 바닥과 같은 질감을 깔끔하게 계속해서 반복합니다.

Compared with large diffusion-based inpainting systems, how is LaMa commonly positioned?

LaMa is a convolutional inpainting approach built around FFCs and is often used where an efficient fill is useful; speed and memory depend on the implementation and hardware.