Commit ·
f057048
1
Parent(s): fc8583e
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,44 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
---
|
| 4 |
+
A custom pipeline to add inpainting support to T2I-Adapters with the SDXL model.
|
| 5 |
+
|
| 6 |
+
To use T2I-Adapters with SDXL, ensure you have diffusers installed via the `t2iadapterxl` branch like so:
|
| 7 |
+
```bash
|
| 8 |
+
pip install git+https://github.com/huggingface/diffusers.git@t2iadapterxl
|
| 9 |
+
```
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
The following is an example on how to use this pipeline along with a sketch T2I-Adapter:
|
| 13 |
+
```py
|
| 14 |
+
>>> import torch
|
| 15 |
+
>>> from diffusers import DiffusionPipeline, T2IAdapter
|
| 16 |
+
>>> from diffusers.utils import load_image
|
| 17 |
+
>>> from PIL import Image
|
| 18 |
+
|
| 19 |
+
>>> adapter = T2IAdapter.from_pretrained(
|
| 20 |
+
... "TencentARC/t2i-adapter-sketch-sdxl-1.0", torch_dtype=torch.float16, variant="fp16"
|
| 21 |
+
... ).to("cuda")
|
| 22 |
+
|
| 23 |
+
>>> pipe = DiffusionPipeline.from_pretrained(
|
| 24 |
+
... "stabilityai/stable-diffusion-xl-base-1.0",
|
| 25 |
+
... torch_dtype=torch.float16,
|
| 26 |
+
... variant="fp16",
|
| 27 |
+
... use_safetensors=True,
|
| 28 |
+
... custom_pipeline="jakebabbidge/sdxl-adapter-inpaint",
|
| 29 |
+
... adapter=adapter
|
| 30 |
+
... ).to("cuda")
|
| 31 |
+
|
| 32 |
+
>>> image = Image.open(image_path).convert("RGB")
|
| 33 |
+
>>> mask = Image.open(mask_path).convert("RGB")
|
| 34 |
+
>>> adapter_sketch = Image.open(adapter_sketch_path).convert("RGB")
|
| 35 |
+
|
| 36 |
+
>>> result_image = pipe(
|
| 37 |
+
... image=image,
|
| 38 |
+
... mask_image=mask,
|
| 39 |
+
... adapter_image=adapter_sketch,
|
| 40 |
+
... prompt="a photo of a dog in real world, high quality",
|
| 41 |
+
... negative_prompt="extra digit, fewer digits, cropped, worst quality, low quality",
|
| 42 |
+
... num_inference_steps=50
|
| 43 |
+
... ).images[0]
|
| 44 |
+
```
|