← Latest papers
🤖 machine learning

Inpainting Insights: Elevating Visual XAI with Photorealistic Perturbations

This paper proposes enhancing the LIME explainability method by replacing traditional pixel-based perturbations with generative inpainting to produce photorealistic, in-distribution samples that significantly improve the quality and reliability of visual explanations for machine learning models.

Original authors: Josef Lindl, Mariana Chaves, Damien Garreau

Published 2026-07-20
📖 7 min read🧠 Deep dive

Original authors: Josef Lindl, Mariana Chaves, Damien Garreau

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are trying to figure out how a super-smart robot sees the world. You ask it, "What makes this picture look like a dog?" and it says, "The ears!" But how do you know it's not just guessing because of a weird shadow or a specific color? This is the world of Explainable AI (XAI). It's the field dedicated to peering inside the "black box" of artificial intelligence to see what's actually happening. One popular way to do this is called perturbation. Think of it like playing a game of "What if?" with a photo. You cover up parts of the image—maybe the dog's ears or tail—and ask the robot, "Does it still think this is a dog?" If the robot suddenly stops recognizing the dog when you cover the ears, you know the ears are important.

However, there's a catch. If you just cover the ears with a big, ugly gray square, you aren't really testing the robot's understanding of a dog; you're testing its reaction to a giant gray blob. The robot might get confused by the weird, unnatural square and give you a wrong answer about what's important. This paper tackles that problem. It suggests that instead of using boring, fake gray squares to hide parts of an image, we should use a "magic eraser" that fills in the missing spots with realistic, photorealistic details that look like they belong there. This way, the robot is only confused by the missing object, not by a weird artifact, giving us a much clearer answer about what it's actually looking at.


The Problem: Ugly Squares and Confused Robots

In the world of computer vision, AI models are getting incredibly good at spotting things, but they are also getting harder to understand. To fix this, researchers use tools like LIME (Local Interpretable Model-agnostic Explanations). LIME works by taking an image, chopping it into little puzzle pieces called "superpixels," and then hiding some of those pieces to see how the AI's prediction changes.

The traditional way to hide a piece is to paint over it with a solid color, like gray or black. The authors of this paper argue that this is a bit like trying to test a chef's ability to recognize a cake by replacing the frosting with a block of concrete. The concrete isn't part of the cake, and it doesn't look like anything natural. When the AI sees this "concrete," it might freak out and make a prediction that has nothing to do with the cake, leading to a confusing explanation.

The paper shows that these "ugly squares" (deterministic occlusion) often fail. For example, in a test with an image of a band-aid, standard methods using gray squares or other simple color replacements completely missed the band-aid as the most important part of the image. They were too distracted by the unnatural gray blobs they created.

The Solution: The "Magic Inpainting" Trick

To solve this, the authors introduce a new method called LILI (Leveraging Inpainting for Local Interpretability). Instead of painting over the hidden puzzle pieces with gray paint, LILI uses a generative AI model called LaMa to "inpaint" the image.

Think of inpainting like a very talented artist who can look at a hole in a photo and paint exactly what should be there based on the surroundings. If you hide a band-aid, LaMa doesn't put a gray square; it paints a patch of skin that looks exactly like the skin around the band-aid. This creates a "photorealistic perturbation." The AI model sees a picture that looks natural, except the band-aid is gone. This forces the AI to rely on its actual knowledge of what a band-aid looks like, rather than reacting to a weird gray square.

But there was a second problem. Even with the magic artist, the edges of the hidden area sometimes left tiny, invisible clues (artifacts) that the AI could still see. To fix this, the authors added a "mask expansion" step. Imagine if, instead of just hiding the band-aid, you also hid a tiny bit of the skin around it. This ensures the magic artist has to fill in the whole area with new background skin, completely erasing any trace of the original object.

What They Found: Realism Wins

The team tested LILI against the old method (LIME with gray squares) and an earlier attempt that used a different inpainting model called DeepFill (LIME-G). They ran hundreds of tests on images from the ImageNet dataset, using a standard AI model called InceptionV3 to do the recognizing.

1. The Images Look Better
The authors measured how "real" the fake images looked using a score called the Fréchet Inception Distance (FID). A lower score means the fake images are more similar to real photos.

  • The old LIME method (gray squares) scored 30.532.
  • The previous inpainting method (LIME-G with DeepFill) scored 56.524 (which was surprisingly worse, likely because the model wasn't as good).
  • The new LILI method scored 6.727.
    This huge drop in score proves that LILI creates images that are much closer to the real data distribution. They look natural, not like a photo with a gray blob slapped on it.

2. The Explanations Are More Accurate
To see if the explanations were actually better, they used a "saliency metric." This measures how well the explanation highlights the most important parts of the image. Lower scores are better here.

  • LILI with a 3-pixel mask expansion achieved the best scores, beating both the old LIME and the LIME-G method.
  • For instance, in the band-aid example, only LILI correctly identified the band-aid as the most important feature. The other methods got distracted by the background or the artifacts.

3. Stability and Speed
The researchers also checked if the explanations were consistent. If you run the test ten times, do you get the same answer?

  • The old LIME was the most stable (agreement score of 0.889), followed closely by LILI (0.852).
  • LIME-G was less stable (0.723).
  • The authors note that LILI is slightly less stable than the old gray-square method because the "magic artist" (LaMa) can sometimes paint slightly different backgrounds depending on the exact mask. However, this is a small price to pay for getting the right answer.
  • As for speed, LILI takes a bit longer. The old LIME took about 4.4 seconds per image, while LILI took about 12.5 seconds. This is because the "magic artist" has to do extra work to paint the missing parts, but it's still much faster than other high-tech methods that use diffusion models.

The Takeaway

The paper concludes that by swapping out ugly, fake gray squares for realistic, AI-generated background filling, we can get much better explanations of how AI sees the world. The LILI method suggests that photorealistic perturbations align better with how the AI was trained, leading to more trustworthy results. While it takes a little more computing power and requires careful tuning of the "mask expansion" to avoid leaving clues, the trade-off is worth it. The authors suggest that this approach helps us trust AI more, especially in situations where we need to know exactly why a computer made a decision, without the confusion caused by unnatural artifacts.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →