huggingface / huggingface/diffusers

Inpainting produces results that are uneven with input image

Offen
#5,808 43 Kommentare 2 Reaktionen 1 zugewiesene Person Beansprucht von @yiyixuxu Auf GitHub ansehen
bug inpainting stale
Vorherrschende Sprache
Python
Sterne
34.5k
Forks
7.3k
Ø Merge
3 T. 3 Std.
Gemergte PRs (30 T.)
91

Beschreibung

### Describe the bug

SD inpainting works fine only if mask is absolutely perfect.
Otherwise, there are always visible seams at the edge of the mask, and uneven colors between inpainted and input image.

I've tried manually assembling latents and using them for `image` and `mask_image` instead of images as well as manually assembling entire `masked_image_latent` - results are the same so i left reproduction as simple as possible.

Same behavior is visible in SD and SD-XL pipelines, using base model as well as dedicated inpainting models.
Non-diffuser inpainting implementations such as legacy A1111 implementation does not have this issue.

i've attached a very simple reproduction code that
1. generates image
2. creates mask as a square in the middle of the image.
3. runs inpainting pipeline

### Reproduction

```py
import torch
import diffusers
from PIL import Image

model = '/mnt/f/Models/stable-diffusion/cyan-2.5d-v1.safetensors'

pipe0 = diffusers.StableDiffusionPipeline.from_single_file(model).to('cuda')
print(pipe0.__class__.__name__)
base = pipe0('seashore').images[0]
print(base)

mask = Image.new('L', base.size, 0)
square = Image.new('L', (base.size[0]//2, base.size[1]//2), 255)
mask.paste(square, (base.size[0]//4, base.size[1]//4))
print(mask)

pipe1 = diffusers.AutoPipelineForInpainting.from_pipe(pipe0).to('cuda')
print(pipe1.__class__.__name__)
inpaint = pipe1('house', image=base, mask_image=mask, strength=0.75).images[0]
print(inpaint)

base.save('base.png')
mask.save('mask.png')
inpaint.save('inpaint.png')
```

### Logs

_No response_

### System Info

diffusers==0.23.0

### Who can help?

@patrickvonplaten @yiyixuxu @DN6 @sayakpaul

### Examples

![base](https://github.com/huggingface/diffusers/assets/57876960/3aaf9276-0504-4176-a2fc-4ee13414e12b)

![mask](https://github.com/huggingface/diffusers/assets/57876960/b1198d54-9a4d-486d-bf9f-d0c60e4e6864)

![inpaint](https://github.com/huggingface/diffusers/assets/57876960/15c635be-2c67-42da-9a27-031ba8c3ed62)

note: issue was originally reported at https://github.com/vladmandic/automatic/issues/2501 which you can check for additional examples.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.