Python25 commited on
Commit
8f54e56
·
verified ·
1 Parent(s): 4efb167

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from diffusers import StableDiffusionPipeline
3
+ import torch
4
+
5
+ pipe = StableDiffusionPipeline.from_pretrained(
6
+ "CompVis/stable-diffusion-v1-4",
7
+ torch_dtype=torch.float16,
8
+ revision="fp16"
9
+ )
10
+ pipe = pipe.to("cuda" if torch.cuda.is_available() else "cpu")
11
+
12
+ def generate(prompt):
13
+ image = pipe(prompt).images[0]
14
+ return image
15
+
16
+ gr.Interface(fn=generate, inputs="text", outputs="image").launch()