MINEOGO commited on
Commit
9a1cdb3
·
verified ·
1 Parent(s): 639fa5f

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
+ # Load Stable Diffusion model from Hugging Face
6
+ pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v-1-4-original", torch_dtype=torch.float32)
7
+ pipe = pipe.to("cuda") # If you have a GPU available, use it. Otherwise, change to "cpu"
8
+
9
+ def generate_image(prompt):
10
+ image = pipe(prompt).images[0]
11
+ return image
12
+
13
+ # Set up the Gradio interface
14
+ gr.Interface(fn=generate_image, inputs="text", outputs="image").launch()