question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inpainting example is using data from the masked parts with strength 1

See original GitHub issue

Describe the bug

It is my understanding that if we provide strength=1 to the inpainting pipeline, that the model would try to fill the missing parts without taking into account what was in the image before (where the mask is).

It does not appear to be the case and is really apparent when trying to zoomout of a picture. In that case, the prediction will very often fill this area with white.

Using the following mask (open the image in a new tab to see the white border):

zoomout_mask

I create prediction first by keeping the white border in the init_image, then I create prediction by filling the white border with similar colors (with gimp).

keeping white border:

zoomout_white

Filling white border with gimp:

zoomout_filled

Here is my result with the white border:

white_result

Here is my result with the filled border:

filled_result

It is clear that the model is keeping data about the parts which should be cropped by the mask.

Reproduction

The code I used to generate the grids is here

Add 3 images above named zoomout_mask.png zoomout_white.png zoomout_filled.png in the /tmp/inpainting folder and run the above script.

Logs

No response

System Info

diffusers version: commit 5cbed8e0d157f65d3ddc2420dfd09f2df630e978

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nagolinccommented, Aug 26, 2022

@leszekhanusz Adding the un-noised latents was what I originally tried, but @jackloomen pointed out here (https://github.com/huggingface/diffusers/pull/241#issuecomment-1226283542) that was causing the final inpainted image to be blurry.

Worth noting that @eteriaai has apparently figured out a much better method (https://twitter.com/EteriaAI/status/1563018093055553539), so hopefully we’ll find out what that is soon.

1reaction
nagolinccommented, Aug 26, 2022

@leszekhanusz Interesting.

I added a hack here (https://github.com/huggingface/diffusers/compare/main...nagolinc:diffusers:inpainting-fix) that fixes this. But I wish I understood better why it was happening in the first place.

(this is using white borders and strength=1.0 and my changes)

grid6

Read more comments on GitHub >

github_iconTop Results From Across the Web

runwayml/stable-diffusion-inpainting - Hugging Face
Stable Diffusion Inpainting is a latent text-to-image diffusion model capable of generating photo-realistic images given any text input, with the extra ...
Read more >
Inpainting missing data — pyFAI 0.22.0a11 documentation
Missing data in an image can be an issue, especially when one wants to perform Fourier analysis. This tutorial explains how to fill-up...
Read more >
Stable Diffusion script with inpainting mask - myByways
In my case, I use a mask to specify which parts of an image should be replaced by Stable Diffusion. Both the image...
Read more >
File:Demonstration of inpainting and outpainting using Stable ...
This image aims to illustrate the process in which Stable Diffusion can be used to perform both inpainting and outpainting, as one part...
Read more >
Resolution-robust Large Mask Inpainting with ... - YouTube
lama # inpainting #deeplearningAt the end of the video is an interview with the paper authors!LaMa is a system that is amazing at...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found