Scorpsuki commited on
Commit
d5fe8e7
·
verified ·
1 Parent(s): 0b92a16

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)
7
+ pipe = pipe.to("cuda" if torch.cuda.is_available() else "cpu")
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()