SD-XL Inpainting 0.1 is a latent text-to-image diffusion model capable of generating photo-realistic images given any text input, with the extra capability of inpainting the pictures by using a mask.
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]
The model is intended for research purposes only. Possible research areas and tasks include
Excluded uses are described below.
The model was not trained to be factual or true representations of people or events, and therefore using the model to generate such content is out-of-scope for the abilities of this model.
While the capabilities of image generation models are impressive, they can also reinforce or exacerbate social biases.