Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
from PIL import Image, ImageDraw, ImageFont
|
| 3 |
import torch
|
| 4 |
from diffusers import StableDiffusionPipeline
|
|
@@ -258,52 +258,4 @@ custom_css = ""
|
|
| 258 |
try:
|
| 259 |
with open("style.css", "r") as f:
|
| 260 |
custom_css = f.read()
|
| 261 |
-
except FileNotFoundError:
|
| 262 |
-
print("Warning: style.css not found. Running without custom CSS. Please ensure 'style.css' is in the same directory.")
|
| 263 |
-
|
| 264 |
-
# --- Gradio Interface ---
|
| 265 |
-
iface = gr.Interface(
|
| 266 |
-
fn=generate_comic_panel,
|
| 267 |
-
inputs=gr.Textbox(
|
| 268 |
-
lines=2,
|
| 269 |
-
placeholder="Describe your scene, e.g., 'A cat wearing a superhero cape flying over a city at sunset.'",
|
| 270 |
-
label="Scene Description for Comic Panel"
|
| 271 |
-
),
|
| 272 |
-
outputs=[
|
| 273 |
-
gr.Textbox(label="AI-Generated Story", lines=5, interactive=False, max_lines=10),
|
| 274 |
-
gr.Textbox(label="AI-Generated Dialogue", lines=3, interactive=False, max_lines=5),
|
| 275 |
-
gr.Image(label="Comic Panel Art with Dialogue", type="pil")
|
| 276 |
-
],
|
| 277 |
-
title="🦸♂️ Fantastic AI 🤖 Comic Generator. 💥",
|
| 278 |
-
description=(
|
| 279 |
-
"""<span style="font-size: 1.25em; color: var(--primary-accent-color); display: block; margin-bottom: 15px; font-weight: 600;">
|
| 280 |
-
Generate a unique comic scene using advanced AI models! Provide a scene description, and the AI will craft a short story, generate a punchy dialogue, and create a stylized comic panel image.
|
| 281 |
-
</span>"""
|
| 282 |
-
# ... (inside your gr.Interface description) ...
|
| 283 |
-
description=(
|
| 284 |
-
"""<span style="font-size: 1.25em; color: var(--primary-accent-color); display: block; margin-bottom: 15px; font-weight: 600;">
|
| 285 |
-
Generate a unique comic scene using advanced AI models! Provide a scene description, and the AI will craft a short story, generate a punchy dialogue, and create a stylized comic panel image.
|
| 286 |
-
</span>"""
|
| 287 |
-
f'<br><img src="file=test.png" alt="Test Image" style="max-width: 100px; height: auto; margin-top: 10px;">'
|
| 288 |
-
# Comment out or remove these lines temporarily:
|
| 289 |
-
# f'<br><img src="file=a_dynamic_cityscape.png" alt="Dynamic Cityscape" style="max-width: 100%; height: auto; margin-top: 10px;">'
|
| 290 |
-
# f'<br><img src="file=fantastic_comic_template.png" alt="Comic Template" style="max-width: 100%; height: auto; margin-top: 10px;">'
|
| 291 |
-
"<br><b>Note:</b> This version is optimized for CPU, so generation might be slower than on GPU due to model size and computational demands."
|
| 292 |
-
),
|
| 293 |
-
# ... (rest of your Gradio interface) ...
|
| 294 |
-
"<br><b>Note:</b> This version is optimized for CPU, so generation might be slower than on GPU due to model size and computational demands."
|
| 295 |
-
),
|
| 296 |
-
allow_flagging="auto",
|
| 297 |
-
examples=[
|
| 298 |
-
["A mischievous robot trying to bake a cake, making a huge sugary mess."],
|
| 299 |
-
["A clever detective dog investigating a missing bone in a spooky old mansion."],
|
| 300 |
-
["Two alien astronauts playing a strategic game of chess on the surface of the moon, with Earth shimmering in the background."],
|
| 301 |
-
["A fantasy hero battling a giant marshmallow monster in a candy forest."],
|
| 302 |
-
["A superhero squirrel saving a lost acorn from a black hole."]
|
| 303 |
-
],
|
| 304 |
-
cache_examples=False,
|
| 305 |
-
css=custom_css
|
| 306 |
-
)
|
| 307 |
-
|
| 308 |
-
if __name__ == "__main__":
|
| 309 |
-
iface.launch(share=True)
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
from PIL import Image, ImageDraw, ImageFont
|
| 3 |
import torch
|
| 4 |
from diffusers import StableDiffusionPipeline
|
|
|
|
| 258 |
try:
|
| 259 |
with open("style.css", "r") as f:
|
| 260 |
custom_css = f.read()
|
| 261 |
+
except FileNotFoundError:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|