Closed
Description
Describe the bug
Hi, I recently found the update for inpainting with strength, it's really cool. code
But when using EulerAncestralDiscreteScheduler, just simply set strength as 0.5 or other values<1, the inpaint pipeline fails.
I'm not familiar with the math stuff in diffusion, but it seems that it's the scale process that leads to the problem.
When I rescale the latents back after the preparing latents function with latents = latents / self.scheduler.init_noise_sigma
before the denoise process by unet, the results seems to be good.
# for EulerAncestralDiscreteScheduler, the init_noise_sigma is 14.6146
# for DPMSolverMultistepScheduler, the init_noise_sigma is 1.0
latents = latents * self.scheduler.init_noise_sigma
return latents
input and mask
result
Reproduction
import diffusers
import torch
from PIL import Image
from diffusers import StableDiffusionInpaintPipeline
pipe = StableDiffusionInpaintPipeline.from_pretrained('runwayml/stable-diffusion-inpainting', torch_dtype=torch.float16).to('cuda')
pipe.safety_checker = None
pipe.scheduler = diffusers.EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
image_pil = Image.open('./test/images/girl.png')
target_mask = Image.open('./test/images/girl_mask.png')
inpainted_image = pipe(
prompt="1girl, holding flowers, best quality, masterpiece, realistic, highres, ultral high details", negative_prompt="nsfw, breasts, nude, lowres, bad anatomy, bad hands, cropped, worst quality", image=image_pil, mask_image=target_mask,
height=image_pil.size[1], width=image_pil.size[0],strength=0.5,
num_inference_steps=30, guidance_scale=9,
).images[0]
Logs
No response
System Info
diffusers
version: 0.17.0.dev0- Platform: Linux-5.19.0-35-generic-x86_64-with-glibc2.35
- Python version: 3.10.9
- PyTorch version (GPU?): 2.0.0+cu117 (True)
- Huggingface_hub version: 0.13.3
- Transformers version: 4.26.0
- Accelerate version: 0.18.0
- xFormers version: 0.0.15.dev+0bad001.d20230403
- Using GPU in script?:
- Using distributed or parallel set-up in script?: