Alpha108 commited on
Commit
e98a644
·
verified ·
1 Parent(s): e5074d2

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from diffusers import StableDiffusionPipeline
3
+ import torch
4
+
5
+ # Load model from Hugging Face Hub
6
+ pipe = StableDiffusionPipeline.from_pretrained(
7
+ "stabilityai/stable-diffusion-2",
8
+ torch_dtype=torch.float16
9
+ ).to("cuda")
10
+
11
+ def generate_image(prompt):
12
+ image = pipe(prompt).images[0]
13
+ return image
14
+
15
+ # Gradio UI
16
+ gr.Interface(
17
+ fn=generate_image,
18
+ inputs=gr.Textbox(label="Enter your prompt"),
19
+ outputs="image",
20
+ title="AI Image Generator"
21
+ ).launch()