Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,32 +1,34 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
-
|
| 4 |
-
import numpy as np
|
| 5 |
-
from diffusers import DiffusionPipeline
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
torch.
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
return
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
gr.
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
+
from diffusers import AutoPipelineForText2Image
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
# Model configuration
|
| 6 |
+
MODEL_ID = "stabilityai/sd-turbo"
|
| 7 |
+
DEVICE = "cpu"
|
| 8 |
|
| 9 |
+
pipe = AutoPipelineForText2Image.from_pretrained(
|
| 10 |
+
MODEL_ID,
|
| 11 |
+
torch_dtype=torch.float32,
|
| 12 |
+
)
|
| 13 |
+
pipe.to(DEVICE)
|
| 14 |
+
|
| 15 |
+
def generate_image(prompt: str):
|
| 16 |
+
if not prompt.strip():
|
| 17 |
+
return None
|
| 18 |
+
result = pipe(
|
| 19 |
+
prompt,
|
| 20 |
+
num_inference_steps=4, # Fast rendering
|
| 21 |
+
guidance_scale=0.0, # More realistic, less overexposed
|
| 22 |
+
)
|
| 23 |
+
return result.images[0]
|
| 24 |
+
|
| 25 |
+
demo = gr.Interface(
|
| 26 |
+
fn=generate_image,
|
| 27 |
+
inputs=gr.Textbox(label="Enter your image prompt"),
|
| 28 |
+
outputs=gr.Image(label="Generated Image"),
|
| 29 |
+
title="Freeverse AI Studio 🎨",
|
| 30 |
+
description="Generate ultra-realistic AI images using Stable Diffusion Turbo (Freeverse AI).",
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
if __name__ == "__main__":
|
| 34 |
+
demo.launch()
|