Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- app.py +24 -0
- readme.md +13 -0
- requirements.txt +6 -0
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from diffusers import StableDiffusionPipeline
|
3 |
+
import torch
|
4 |
+
|
5 |
+
# Load model
|
6 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
7 |
+
"runwayml/stable-diffusion-v1-5",
|
8 |
+
torch_dtype=torch.float16,
|
9 |
+
revision="fp16"
|
10 |
+
)
|
11 |
+
pipe.to("cuda")
|
12 |
+
|
13 |
+
def generate(prompt):
|
14 |
+
image = pipe(prompt).images[0]
|
15 |
+
return image
|
16 |
+
|
17 |
+
# Gradio Interface
|
18 |
+
gr.Interface(
|
19 |
+
fn=generate,
|
20 |
+
inputs=gr.Textbox(label="Enter your prompt", placeholder="e.g. A dragon flying over a city"),
|
21 |
+
outputs=gr.Image(type="pil", label="Generated Image"),
|
22 |
+
title="🖼️ Text to Image Generator",
|
23 |
+
description="Enter a prompt and watch it turn into an AI-generated image using Stable Diffusion v1.5"
|
24 |
+
).launch()
|
readme.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# 🖼️ Text to Image Generator
|
2 |
+
|
3 |
+
This is a Hugging Face Space using **Gradio** and **Stable Diffusion v1.5** (`runwayml/stable-diffusion-v1-5`) to generate images from text prompts.
|
4 |
+
|
5 |
+
## How to Use
|
6 |
+
1. Enter a text prompt like `A cat astronaut in space`.
|
7 |
+
2. Click `Submit`.
|
8 |
+
3. Wait for the image to generate!
|
9 |
+
|
10 |
+
Built using:
|
11 |
+
- 🤗 Diffusers
|
12 |
+
- 🧠 Stable Diffusion v1.5
|
13 |
+
- 🌐 Gradio
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
diffusers
|
3 |
+
transformers
|
4 |
+
accelerate
|
5 |
+
safetensors
|
6 |
+
gradio
|