Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,8 @@ from diffusers import StableDiffusionPipeline, EulerAncestralDiscreteScheduler
|
|
| 4 |
import gradio as gr
|
| 5 |
from PIL import Image
|
| 6 |
import io
|
| 7 |
-
import
|
|
|
|
| 8 |
import time
|
| 9 |
|
| 10 |
# Force CPU usage
|
|
@@ -76,14 +77,14 @@ def generate_image(prompt):
|
|
| 76 |
|
| 77 |
print("Image generated successfully!")
|
| 78 |
|
| 79 |
-
#
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
|
| 84 |
-
return
|
| 85 |
|
| 86 |
-
# Create the Gradio Interface
|
| 87 |
demo = gr.Interface(
|
| 88 |
fn=generate_image,
|
| 89 |
inputs=gr.Textbox(
|
|
@@ -91,7 +92,7 @@ demo = gr.Interface(
|
|
| 91 |
lines=2,
|
| 92 |
placeholder="A dragon reading a book under a magical tree"
|
| 93 |
),
|
| 94 |
-
outputs=gr.File(label="Download Generated Illustration"),
|
| 95 |
title="Premium Children's Book Illustrator 🤖🎨",
|
| 96 |
description="Generating high-quality, sharp, detailed images for your stories. Enter a scene description."
|
| 97 |
)
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
from PIL import Image
|
| 6 |
import io
|
| 7 |
+
import tempfile
|
| 8 |
+
import os
|
| 9 |
import time
|
| 10 |
|
| 11 |
# Force CPU usage
|
|
|
|
| 77 |
|
| 78 |
print("Image generated successfully!")
|
| 79 |
|
| 80 |
+
# Create a temporary file and save the image
|
| 81 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix='.png') as tmp_file:
|
| 82 |
+
image.save(tmp_file, format='PNG')
|
| 83 |
+
tmp_file_path = tmp_file.name
|
| 84 |
|
| 85 |
+
return tmp_file_path
|
| 86 |
|
| 87 |
+
# Create the Gradio Interface
|
| 88 |
demo = gr.Interface(
|
| 89 |
fn=generate_image,
|
| 90 |
inputs=gr.Textbox(
|
|
|
|
| 92 |
lines=2,
|
| 93 |
placeholder="A dragon reading a book under a magical tree"
|
| 94 |
),
|
| 95 |
+
outputs=gr.File(label="Download Generated Illustration"),
|
| 96 |
title="Premium Children's Book Illustrator 🤖🎨",
|
| 97 |
description="Generating high-quality, sharp, detailed images for your stories. Enter a scene description."
|
| 98 |
)
|