Zhenhong commited on
Commit
d584767
1 Parent(s): 5d4ed8e

Add application file

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -1,7 +1,20 @@
1
  import gradio as gr
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
 
 
 
 
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()