Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -184,7 +184,89 @@ Only provide the raw values, no headers.
|
|
| 184 |
|
| 185 |
|
| 186 |
with gr.Blocks(
|
| 187 |
-
title="Comic Generator", css="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
gr.Markdown("## π¬ AI Scene-by-Scene Story Creator")
|
| 189 |
gr.Markdown("Describe your story one scene at a time, with AI-generated images, summaries, and explanations.")
|
| 190 |
|
|
@@ -206,12 +288,10 @@ with gr.Blocks(
|
|
| 206 |
bg_style = gr.Dropdown(label="π¨ Background Style", choices=["Realistic", "Cartoon", "Fantasy", "Dark Fantasy"], value="Fantasy")
|
| 207 |
|
| 208 |
with gr.Row():
|
| 209 |
-
generate_btn = gr.Button("β Generate This Scene")
|
| 210 |
-
ai_coauthor_btn = gr.Button("π€ Let AI Write This One")
|
| 211 |
-
recreate_btn = gr.Button("π Recreate This Scene")
|
| 212 |
-
next_btn = gr.Button("βοΈ Next Scene")
|
| 213 |
-
# last_image_display = gr.Image(label="πΈ Last Scene Image", type="pil")
|
| 214 |
-
|
| 215 |
|
| 216 |
status = gr.Markdown()
|
| 217 |
image_output = gr.Image(label="πΌοΈ Scene Image", type="pil")
|
|
@@ -219,10 +299,10 @@ with gr.Blocks(
|
|
| 219 |
explanation_output = gr.Textbox(label="π Scene Explanation", lines=6)
|
| 220 |
|
| 221 |
with gr.Row():
|
| 222 |
-
tts_btn = gr.Button("π Read Aloud")
|
| 223 |
tts_audio = gr.Audio(label="Audio", autoplay=False)
|
| 224 |
|
| 225 |
-
done_btn = gr.Button("β
Finalize Story & Export", visible=False)
|
| 226 |
txt_file = gr.File(label="π Explanations (.txt)")
|
| 227 |
pdf_file = gr.File(label="π Scene PDF")
|
| 228 |
|
|
@@ -245,7 +325,6 @@ with gr.Blocks(
|
|
| 245 |
]
|
| 246 |
)
|
| 247 |
|
| 248 |
-
|
| 249 |
recreate_btn.click(
|
| 250 |
fn=generate_scene,
|
| 251 |
inputs=[
|
|
@@ -260,7 +339,6 @@ with gr.Blocks(
|
|
| 260 |
]
|
| 261 |
)
|
| 262 |
|
| 263 |
-
|
| 264 |
next_btn.click(
|
| 265 |
fn=generate_scene,
|
| 266 |
inputs=[
|
|
@@ -271,18 +349,16 @@ with gr.Blocks(
|
|
| 271 |
outputs=[
|
| 272 |
image_output, summary_output, explanation_output,
|
| 273 |
scene_images, scene_summaries, scene_explanations,
|
| 274 |
-
status, done_btn
|
|
|
|
| 275 |
)
|
| 276 |
|
| 277 |
-
|
| 278 |
-
|
| 279 |
ai_coauthor_btn.click(
|
| 280 |
fn=ai_write_scene,
|
| 281 |
inputs=[theme, scene_total, scene_summaries],
|
| 282 |
outputs=[character_names, dialogue, dialogue_speaker, char_styles, char_moods, bg_style, status]
|
| 283 |
)
|
| 284 |
|
| 285 |
-
|
| 286 |
done_btn.click(
|
| 287 |
fn=finalize_story,
|
| 288 |
inputs=[scene_images, scene_explanations],
|
|
|
|
| 184 |
|
| 185 |
|
| 186 |
with gr.Blocks(
|
| 187 |
+
title="Comic Generator", css="""
|
| 188 |
+
body {
|
| 189 |
+
background: #f2f6fa;
|
| 190 |
+
}
|
| 191 |
+
.gradio-container {
|
| 192 |
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
|
| 193 |
+
border-radius: 16px;
|
| 194 |
+
padding: 24px;
|
| 195 |
+
background: #ffffff;
|
| 196 |
+
font-family: 'Segoe UI', sans-serif;
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
.gr-button {
|
| 200 |
+
border-radius: 8px;
|
| 201 |
+
font-weight: 600;
|
| 202 |
+
transition: 0.3s all ease-in-out;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
/* Button Styling via IDs */
|
| 206 |
+
#generate-btn {
|
| 207 |
+
background-color: #007acc;
|
| 208 |
+
color: white;
|
| 209 |
+
}
|
| 210 |
+
#ai-write-btn {
|
| 211 |
+
background-color: #34495e;
|
| 212 |
+
color: white;
|
| 213 |
+
}
|
| 214 |
+
#recreate-btn {
|
| 215 |
+
background-color: #5dade2;
|
| 216 |
+
color: white;
|
| 217 |
+
}
|
| 218 |
+
#next-btn {
|
| 219 |
+
background-color: #85929e;
|
| 220 |
+
color: white;
|
| 221 |
+
}
|
| 222 |
+
#done-btn {
|
| 223 |
+
background-color: #2e86c1;
|
| 224 |
+
color: white;
|
| 225 |
+
}
|
| 226 |
+
#tts-btn {
|
| 227 |
+
background-color: #aab7b8;
|
| 228 |
+
color: white;
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
/* Sections */
|
| 232 |
+
.gr-accordion {
|
| 233 |
+
background-color: #e8f1f9;
|
| 234 |
+
border: 1px solid #d6eaf8;
|
| 235 |
+
border-radius: 10px;
|
| 236 |
+
padding: 8px;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
.gr-markdown h2 {
|
| 240 |
+
color: #2e4053;
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
.gr-textbox textarea,
|
| 244 |
+
.gr-number input,
|
| 245 |
+
.gr-dropdown select {
|
| 246 |
+
border: 1px solid #d0d3d4;
|
| 247 |
+
border-radius: 6px;
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
.gr-image {
|
| 251 |
+
border: 1px solid #d6eaf8;
|
| 252 |
+
background-color: #f8f9f9;
|
| 253 |
+
border-radius: 12px;
|
| 254 |
+
padding: 8px;
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
.gr-audio {
|
| 258 |
+
background-color: #ecf0f1;
|
| 259 |
+
border-radius: 8px;
|
| 260 |
+
padding: 10px;
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
.gr-file {
|
| 264 |
+
background-color: #f7f9f9;
|
| 265 |
+
border: 1px dashed #bfc9ca;
|
| 266 |
+
border-radius: 10px;
|
| 267 |
+
padding: 10px;
|
| 268 |
+
}
|
| 269 |
+
""") as demo:
|
| 270 |
gr.Markdown("## π¬ AI Scene-by-Scene Story Creator")
|
| 271 |
gr.Markdown("Describe your story one scene at a time, with AI-generated images, summaries, and explanations.")
|
| 272 |
|
|
|
|
| 288 |
bg_style = gr.Dropdown(label="π¨ Background Style", choices=["Realistic", "Cartoon", "Fantasy", "Dark Fantasy"], value="Fantasy")
|
| 289 |
|
| 290 |
with gr.Row():
|
| 291 |
+
generate_btn = gr.Button("β Generate This Scene", elem_id="generate-btn")
|
| 292 |
+
ai_coauthor_btn = gr.Button("π€ Let AI Write This One", elem_id="ai-write-btn")
|
| 293 |
+
recreate_btn = gr.Button("π Recreate This Scene", elem_id="recreate-btn")
|
| 294 |
+
next_btn = gr.Button("βοΈ Next Scene", elem_id="next-btn")
|
|
|
|
|
|
|
| 295 |
|
| 296 |
status = gr.Markdown()
|
| 297 |
image_output = gr.Image(label="πΌοΈ Scene Image", type="pil")
|
|
|
|
| 299 |
explanation_output = gr.Textbox(label="π Scene Explanation", lines=6)
|
| 300 |
|
| 301 |
with gr.Row():
|
| 302 |
+
tts_btn = gr.Button("π Read Aloud", elem_id="tts-btn")
|
| 303 |
tts_audio = gr.Audio(label="Audio", autoplay=False)
|
| 304 |
|
| 305 |
+
done_btn = gr.Button("β
Finalize Story & Export", visible=False, elem_id="done-btn")
|
| 306 |
txt_file = gr.File(label="π Explanations (.txt)")
|
| 307 |
pdf_file = gr.File(label="π Scene PDF")
|
| 308 |
|
|
|
|
| 325 |
]
|
| 326 |
)
|
| 327 |
|
|
|
|
| 328 |
recreate_btn.click(
|
| 329 |
fn=generate_scene,
|
| 330 |
inputs=[
|
|
|
|
| 339 |
]
|
| 340 |
)
|
| 341 |
|
|
|
|
| 342 |
next_btn.click(
|
| 343 |
fn=generate_scene,
|
| 344 |
inputs=[
|
|
|
|
| 349 |
outputs=[
|
| 350 |
image_output, summary_output, explanation_output,
|
| 351 |
scene_images, scene_summaries, scene_explanations,
|
| 352 |
+
status, done_btn
|
| 353 |
+
]
|
| 354 |
)
|
| 355 |
|
|
|
|
|
|
|
| 356 |
ai_coauthor_btn.click(
|
| 357 |
fn=ai_write_scene,
|
| 358 |
inputs=[theme, scene_total, scene_summaries],
|
| 359 |
outputs=[character_names, dialogue, dialogue_speaker, char_styles, char_moods, bg_style, status]
|
| 360 |
)
|
| 361 |
|
|
|
|
| 362 |
done_btn.click(
|
| 363 |
fn=finalize_story,
|
| 364 |
inputs=[scene_images, scene_explanations],
|