Jdifb commited on
Commit
8459afb
·
verified ·
1 Parent(s): a73aa9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -1,7 +1,14 @@
 
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return f"Hello, {name}!"
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
1
+ import torch
2
+ from diffusers import StableDiffusionPipeline
3
  import gradio as gr
4
 
5
+ model_id = "runwayml/stable-diffusion-v1-5"
6
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
7
+ pipe.to("cuda")
8
 
9
+ def generate(prompt):
10
+ image = pipe(prompt).images[0]
11
+ return image
12
+
13
+ iface = gr.Interface(fn=generate, inputs="text", outputs="image")
14
+ iface.launch()