Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
9 |
-
|
10 |
-
|
11 |
-
image
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
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()
|
|