File size: 1,416 Bytes
fc8583e
 
 
f057048
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
license: mit
---
A custom pipeline to add inpainting support to T2I-Adapters with the SDXL model.

To use T2I-Adapters with SDXL, ensure you have diffusers installed via the `t2iadapterxl` branch like so:
```bash
pip install git+https://github.com/huggingface/diffusers.git@t2iadapterxl
```


The following is an example on how to use this pipeline along with a sketch T2I-Adapter:
```py
>>> import torch
>>> from diffusers import DiffusionPipeline, T2IAdapter
>>> from diffusers.utils import load_image
>>> from PIL import Image

>>> adapter = T2IAdapter.from_pretrained(
... 	"TencentARC/t2i-adapter-sketch-sdxl-1.0", torch_dtype=torch.float16, variant="fp16"
... ).to("cuda")

>>> pipe = DiffusionPipeline.from_pretrained(
... 	"stabilityai/stable-diffusion-xl-base-1.0",
... 	torch_dtype=torch.float16,
... 	variant="fp16",
... 	use_safetensors=True,
... 	custom_pipeline="jakebabbidge/sdxl-adapter-inpaint",
... 	adapter=adapter
... ).to("cuda")

>>> image = Image.open(image_path).convert("RGB")
>>> mask = Image.open(mask_path).convert("RGB")
>>> adapter_sketch = Image.open(adapter_sketch_path).convert("RGB")

>>> result_image = pipe(
... 	image=image,
... 	mask_image=mask,
... 	adapter_image=adapter_sketch,
... 	prompt="a photo of a dog in real world, high quality",
... 	negative_prompt="extra digit, fewer digits, cropped, worst quality, low quality",
...	num_inference_steps=50
... ).images[0]
```