Zuwa gabaJagora na gaba
CodeFormer Karfin Fuskar Farfadowa
Kayayyakin AI
Kayayyakin AI JAGORA
LaMa (Large Mask Inpainting) na tsarin ayyukan cirewa a cikin hoto daga masu binciken Samsung AI, wanda aka shirya a WACV 2022, wanda ke cike manyan kunkuna a cikin hoto ta amfani da Fourier convolutions don ganin dukkan hoton a lokaci guda.
Saurara wannan jagoraAI da ake ba da labari · ~8 min
An horar da shi kawai a kan girman 256 ta 256, yana aiki a kan manyan hotuna, kuma ƙaramin girmansa da buɗaɗɗen lambar sun sa ya zama injin cire abubuwa na asali a cikin kayan aiki da yawa na kyauta.
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.
04Misali na aiki
Zaɓi hoto tare da abu da ba a so a kan bango mai daidaito, kamar alamar a kan fili mai shuka.
Ƙirƙiri fuskoki daidai da girman hoto, zana abu da ƙaramin iyaka a kusa da shi fari da komai na baya baki.
Shigar da IOPaint tare da pip kuma fara shi tare da samfurin LaMa a CPU, sannan buɗe shafin yanar gizon gida da yake ba da sabis.
Loda hoton, fasa kan abu, kuma gudanar da cike; ko kuma ajiye image.png da image_mask001.png a cikin fayil kuma gudanar da script na hukuma na predict tare da big-lama.
Ƙara kusurwar yankin da aka cike a cikakken ƙuduri kuma duba blur, maimaitattun patches ko layukan da suka karye.
Maimaita tare da hoto inda abu ke zaune a gaban ƙasa mai layi a hangen nesa, kuma kwatanta ingancin cike biyu.
Abin da yake nunawa
Hoton da aka tsaftace da kuma kwatancen kai tsaye na yanayi mai sauƙi da mai wahala. Bango mai sauƙi ya kamata ya cika da kyau, yayin da layukan tiles na hangen nesa za su iya nuna layuka da suka yi kuskure ko ba daidai ba, yanayin da marubutan takardar suka bayyana.
Goge mutane, abubuwa, lahani ko alamar ruwa da ba a so a IOPaint, wani kayan aikin buɗe‑source na Apache-2.0 daga Sanster, mai haɓaka lama-cleaner, wanda ke amfani da LaMa don cirewa kuma yana gudana a CPU, NVIDIA GPU ko Apple Silicon.
Yi inpainting a cikin fayil ɗin hotuna da ke cikin babban ma’ajin advimman/lama ta hanyar adana kowanne mask a matsayin image1_mask001.png a gefen image1.png kuma gudanar da bin/predict.py tare da babban maɓalli na big-lama.
Inganta sakamakon ƙuduri mai girma tare da hanyar ƙara fasali daga Geomagical Labs, wanda ke inganta fasalolin cikin LaMa a lokacin hasashe kuma an kunna shi a cikin lambar hukuma tare da refine=True.
Gudanar da LaMa a kan na’urorin Apple ta hanyar CoreMLaMa, wani canjin al’umma zuwa tsarin Core ML na Apple da aka lissafa a cikin README na ma’ajin hukuma.
Yi gwajin sabon samfurin inpainting akan LaMa a kan Places da CelebA-HQ tare da FID da LPIPS, bayanan da ma’aunin da aka yi amfani da su a takardar asali.
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.
Wasikar kyauta
Labarun AI guda uku da aka tabbatar a kowace safiya ta ranar mako, an rubuta su da Ingilishi a sarari. Kyauta har abada, babu talla.
Imel guda ɗaya kowace rana. Cire rajista a danna ɗaya. Ba mu taɓa siyarwa ko raba adireshin ku ba.
Gwada kanka
Amsa kai tsaye kan kowace amsa, da takardar shedar raba gardama tare da tabbataccen ID da zarar kun wuce kwas.
Taimakawa ilimin AI kyauta. AI Understanding ba riba ce ta 501(c)(3) - babu talla, babu bangon biya, har abada. Ba da gudummawa
LaMa (Inpainting Babban Mask) wani samfurin inpainting na hoto ne daga masu binciken Samsung AI, da aka gabatar a WACV 2022, wanda ke cike manyan ramuka a hotuna ta amfani da Fourier convolutions don ganin duk hoton a lokaci guda. An horar da shi kawai a kan yankuna 256 da 256, yana aiki a kan manyan hotuna, kuma ƙaramin girma da lambar buɗe‑source ya sanya shi injin cire abubuwa na tsoho a cikin kayan aiki masu yawa na kyauta.
LaMa yana amfani da Fast Fourier Convolutions (FFCs), waɗanda ke aiki a wani yanki a cikin yankin mitar don samar da filin karɓar duniya a cikin layi ɗaya.
Saboda FFCs suna ganin ɗaukacin hoton lokaci ɗaya, LaMa na iya ci gaba da haɗin kai da rubutu da lissafi har ma da manyan yankuna da suka ɓace.
Mawallafa sun bayar da rahoton cewa LaMa ya iya aiki a ƙuduri mafi girma fiye da na horo a gwaje-gwajensu; aikin har yanzu yana dogara da hoton da mask.
Juyin juzu'i-yanki ya dace da tsarin lokaci-lokaci, don haka LaMa cikin tsafta yana ci gaba da maimaita laushi kamar bangon bulo da benaye masu tayal.
LaMa wata hanya ce ta inpainting ta convolutional da aka gina a kan FFCs kuma a kan gaba ana amfani da ita inda cike mai inganci yake da amfani; sauri da ƙwaƙwalwa suna dogara da aiwatarwa da kayan aiki.
Ci gaba da koyo
An zaɓi ƙarin jagora don wannan batu
Zuwa gabaJagora na gaba
CodeFormer Karfin Fuskar Farfadowa
Kayayyakin AI