cross-attention
commited on
Commit
•
932136b
1
Parent(s):
a2ba96d
Update README.md
Browse files
README.md
CHANGED
@@ -18,16 +18,30 @@ library_name: diffusers
|
|
18 |
|
19 |
## Diffusers
|
20 |
```python
|
|
|
|
|
|
|
21 |
from diffusers import AsymmetricAutoencoderKL, StableDiffusionInpaintPipeline
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
)
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
image = pipe(prompt=prompt, image=image, mask_image=mask_image).images[0]
|
|
|
31 |
```
|
32 |
|
33 |
### Visual
|
|
|
18 |
|
19 |
## Diffusers
|
20 |
```python
|
21 |
+
from io import BytesIO
|
22 |
+
from PIL import Image
|
23 |
+
import requests
|
24 |
from diffusers import AsymmetricAutoencoderKL, StableDiffusionInpaintPipeline
|
25 |
|
26 |
+
|
27 |
+
def download_image(url: str) -> Image.Image:
|
28 |
+
response = requests.get(url)
|
29 |
+
return Image.open(BytesIO(response.content)).convert("RGB")
|
30 |
+
|
31 |
+
|
32 |
+
prompt = "a photo of a person"
|
33 |
+
img_url = "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/repaint/celeba_hq_256.png"
|
34 |
+
mask_url = "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/repaint/mask_256.png"
|
35 |
+
|
36 |
+
image = download_image(img_url).resize((256, 256))
|
37 |
+
mask_image = download_image(mask_url).resize((256, 256))
|
38 |
+
|
39 |
+
pipe = StableDiffusionInpaintPipeline.from_pretrained("runwayml/stable-diffusion-inpainting")
|
40 |
+
pipe.vae = AsymmetricAutoencoderKL.from_pretrained("cross-attention/asymmetric-autoencoder-kl-x-2")
|
41 |
+
pipe.to("cuda")
|
42 |
|
43 |
image = pipe(prompt=prompt, image=image, mask_image=mask_image).images[0]
|
44 |
+
image.save("image.jpeg")
|
45 |
```
|
46 |
|
47 |
### Visual
|