Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,10 +2,10 @@ import gradio as gr
|
|
| 2 |
from diffusers import StableDiffusionPipeline
|
| 3 |
import torch
|
| 4 |
|
| 5 |
-
# Model Load
|
| 6 |
model_id = "runwayml/stable-diffusion-v1-5"
|
| 7 |
-
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.
|
| 8 |
-
pipe = pipe.to("
|
| 9 |
|
| 10 |
def generate_image(prompt):
|
| 11 |
image = pipe(prompt).images[0]
|
|
@@ -14,10 +14,14 @@ def generate_image(prompt):
|
|
| 14 |
# Gradio Interface
|
| 15 |
iface = gr.Interface(
|
| 16 |
fn=generate_image,
|
| 17 |
-
inputs=gr.Textbox(
|
| 18 |
outputs=gr.Image(label="Generated Image"),
|
| 19 |
title="AI Image Generator",
|
| 20 |
-
description="
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
)
|
| 22 |
|
| 23 |
iface.launch()
|
|
|
|
| 2 |
from diffusers import StableDiffusionPipeline
|
| 3 |
import torch
|
| 4 |
|
| 5 |
+
# Model Load (Free Space safe version)
|
| 6 |
model_id = "runwayml/stable-diffusion-v1-5"
|
| 7 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32)
|
| 8 |
+
pipe = pipe.to("cpu") # Free Space में GPU नहीं होने पर CPU use
|
| 9 |
|
| 10 |
def generate_image(prompt):
|
| 11 |
image = pipe(prompt).images[0]
|
|
|
|
| 14 |
# Gradio Interface
|
| 15 |
iface = gr.Interface(
|
| 16 |
fn=generate_image,
|
| 17 |
+
inputs=gr.Textbox(lines=2, placeholder="Type your image description here...", label="Prompt"),
|
| 18 |
outputs=gr.Image(label="Generated Image"),
|
| 19 |
title="AI Image Generator",
|
| 20 |
+
description="""
|
| 21 |
+
Type any text and get beautiful AI-generated images instantly!
|
| 22 |
+
Free low-res images available. Perfect for posters, social media, and creative art.
|
| 23 |
+
""",
|
| 24 |
+
allow_flagging="never"
|
| 25 |
)
|
| 26 |
|
| 27 |
iface.launch()
|