shahil04 commited on
Commit
4f65bfd
·
verified ·
1 Parent(s): 0247b37

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -21
app.py CHANGED
@@ -1,21 +1,20 @@
1
- import gradio as gr
2
- from diffusers import DiffusionPipeline
3
- import torch
4
-
5
- # Load model
6
-
7
- pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
8
- pipe.to("cuda")
9
-
10
- def generate(prompt):
11
- image = pipe(prompt).images[0]
12
- return image
13
-
14
- # Gradio Interface
15
- gr.Interface(
16
- fn=generate,
17
- inputs=gr.Textbox(label="Enter your prompt", placeholder="e.g. A dragon flying over a city"),
18
- outputs=gr.Image(type="pil", label="Generated Image"),
19
- title="🖼️ Text to Image Generator",
20
- description="Enter a prompt and watch it turn into an AI-generated image using Stable Diffusion v1.5"
21
- ).launch()
 
1
+ import gradio as gr
2
+ from diffusers import DiffusionPipeline
3
+ import torch
4
+
5
+ # Load model
6
+
7
+ pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
8
+
9
+ def generate(prompt):
10
+ image = pipe(prompt).images[0]
11
+ return image
12
+
13
+ # Gradio Interface
14
+ gr.Interface(
15
+ fn=generate,
16
+ inputs=gr.Textbox(label="Enter your prompt", placeholder="e.g. A dragon flying over a city"),
17
+ outputs=gr.Image(type="pil", label="Generated Image"),
18
+ title="🖼️ Text to Image Generator",
19
+ description="Enter a prompt and watch it turn into an AI-generated image using Stable Diffusion v1.5"
20
+ ).launch()