parasmech commited on
Commit
0899ac5
·
verified ·
1 Parent(s): 05a7da5

main file updated

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from diffusers import StableDiffusionPipeline
3
+ import gradio as gr
4
+
5
+
6
+ model_id = "stabilityai/stable-diffusion-2-1"
7
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
8
+ pipe = pipe.to("cuda")
9
+
10
+
11
+ def generate_image(prompt):
12
+ with torch.autocast("cuda"):
13
+ image = pipe(prompt).images[0]
14
+ return image
15
+
16
+
17
+ title = " Image Generator"
18
+ description = """
19
+ This app generates images based on text prompts using the Stable Diffusion model.
20
+ """
21
+
22
+ interface = gr.Interface(
23
+ fn=generate_image,
24
+ inputs=gr.Textbox(label="Enter your text prompt", placeholder="Describe the image you want to generate"),
25
+ outputs=gr.Image(label="Generated Image"),
26
+ title=title,
27
+ description=description,
28
+ )
29
+
30
+ gr.launch()