Spaces:
Runtime error
Runtime error
main file updated
Browse files
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()
|