Views
No views yet

stable-diffusion-xl-base-1.0 weights. The model is trained for 40k steps at resolution 1024x1024 and 5% dropping of the text-conditioning to improve classifier-free classifier-free guidance sampling. For inpainting, the UNet has 5 additional input channels (4 for the encoded masked-image and 1 for the mask itself) whose weights were zero-initialized after restoring the non-inpainting checkpoint. During training, we generate synthetic masks and, in 25% mask everything.1from diffusers import AutoPipelineForInpainting
2from diffusers.utils import load_image
3import torch
4
5pipe = AutoPipelineForInpainting.from_pretrained("diffusers/stable-diffusion-xl-1.0-inpainting-0.1", torch_dtype=torch.float16, variant="fp16").to("cuda")
6
7img_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png"
8mask_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png"
9
10image = load_image(img_url).resize((1024, 1024))
11mask_image = load_image(mask_url).resize((1024, 1024))
12
13prompt = "a tiger sitting on a park bench"
14generator = torch.Generator(device="cuda").manual_seed(0)
15
16image = pipe(
17 prompt=prompt,
18 image=image,
19 mask_image=mask_image,
20 guidance_scale=8.0,
21 num_inference_steps=20, # steps between 15 and 30 work well for us
22 strength=0.99, # make sure to use `strength` below 1.0
23 generator=generator,
24).images[0]image | mask_image |
|---|---|
![]() | ![]() |
prompt | Output |
|---|---|
| a tiger sitting on a park bench | ![]() |