Spaces:
Build error
Build error
Zhenhong
commited on
Commit
•
d584767
1
Parent(s):
5d4ed8e
Add application file
Browse files
app.py
CHANGED
@@ -1,7 +1,20 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from diffusers import StableDiffusionPipeline
|
3 |
+
import torch
|
4 |
|
5 |
+
model_id = "runwayml/stable-diffusion-v1-5"
|
6 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
7 |
+
# pipe = pipe.to("cuda")
|
8 |
|
9 |
+
prompt = "a photo of an astronaut riding a horse on mars"
|
10 |
+
|
11 |
+
# image.save("astronaut_rides_horse.png")
|
12 |
+
|
13 |
+
|
14 |
+
def infer(prompt):
|
15 |
+
image = pipe(prompt).images[0]
|
16 |
+
|
17 |
+
return image
|
18 |
+
|
19 |
+
iface = gr.Interface(fn=infer, inputs=gr.Textbox(lines=1, placeholder="Prompt Here..."), outputs="image")
|
20 |
iface.launch()
|