Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from diffusers import StableDiffusionXLImg2ImgPipeline
|
3 |
+
from diffusers.utils import load_image
|
4 |
+
|
5 |
+
pipe = StableDiffusionXLImg2ImgPipeline.from_pretrained(
|
6 |
+
"stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
|
7 |
+
)
|
8 |
+
pipe = pipe.to("cpu")
|
9 |
+
url = "https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/aa_xl/000000009.png"
|
10 |
+
def run_fn(img_url):
|
11 |
+
init_image = load_image(url).convert("RGB")
|
12 |
+
prompt = "a photo of an astronaut riding a horse on mars"
|
13 |
+
image = pipe(prompt, image=init_image).images
|
14 |
+
return image
|
15 |
+
gr.Interface(fn=run_fn,
|
16 |
+
inputs=text,
|
17 |
+
outputs=image).launch()
|
18 |
+
|