Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -293,10 +293,18 @@ def get_ai_suggestion(field_name, existing_values=None):
|
|
| 293 |
# Story generation function
|
| 294 |
def generate_story(story_details):
|
| 295 |
try:
|
| 296 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
user_prompt = user_dislecxic(
|
| 298 |
story_details.get('target_age_group', '7-9'),
|
| 299 |
-
|
| 300 |
story_details.get('story_style', ''),
|
| 301 |
story_details.get('theme', ''),
|
| 302 |
story_details.get('language', 'English'),
|
|
@@ -347,14 +355,24 @@ def generate_images(image_prompts, art_style):
|
|
| 347 |
try:
|
| 348 |
styled_prompts = []
|
| 349 |
style_descriptions = {
|
| 350 |
-
"Abstract Art": "Digital art in Abstract style with vibrant shapes and patterns, ",
|
| 351 |
-
"Art Deco": "Digital art in Art Deco style with symmetrical designs
|
| 352 |
-
"Art Nouveau": "Digital illustration in Art Nouveau style with intricate floral motifs
|
| 353 |
-
"Bauhaus": "Digital art inspired by Bauhaus movement with geometric shapes
|
| 354 |
-
"Celtic Art": "Digital art in Celtic style with intricate knotwork
|
| 355 |
-
"Chinese Brush Painting": "Digital art in Chinese Brush Painting style with fluid brush strokes, ",
|
| 356 |
-
"Concept Art": "Detailed concept art illustration with rich details
|
| 357 |
-
"Cyber Folk": "Digital art blending traditional folk patterns with futuristic cyber aesthetics, "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 358 |
}
|
| 359 |
|
| 360 |
style_prefix = style_descriptions.get(art_style, "Digital illustration in a ")
|
|
@@ -378,7 +396,7 @@ def generate_images(image_prompts, art_style):
|
|
| 378 |
return None
|
| 379 |
|
| 380 |
# Main UI
|
| 381 |
-
st.title("✨ StoryMii
|
| 382 |
|
| 383 |
# Sidebar navigation
|
| 384 |
page = st.sidebar.radio("Navigation", ["Create Story", "Story Library"])
|
|
@@ -437,22 +455,52 @@ if page == "Create Story":
|
|
| 437 |
|
| 438 |
story_details["target_age_group"] = st.select_slider(
|
| 439 |
"Target Age Group",
|
| 440 |
-
options=["
|
| 441 |
-
value="7-9"
|
|
|
|
| 442 |
)
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 456 |
|
| 457 |
story_details["main_character_attributes"] = st.text_area(
|
| 458 |
"Character Attributes",
|
|
|
|
| 293 |
# Story generation function
|
| 294 |
def generate_story(story_details):
|
| 295 |
try:
|
| 296 |
+
word_limits = {
|
| 297 |
+
"1-3": 50,
|
| 298 |
+
"4-6": 100,
|
| 299 |
+
"7-9": 150,
|
| 300 |
+
"10-12": 200
|
| 301 |
+
}
|
| 302 |
+
word_limit = word_limits[story_details.get('target_age_group', '7-9')]
|
| 303 |
+
|
| 304 |
+
system_prompt = system_dislecxic(story_details.get('target_age_group', '7-9'), word_limit)
|
| 305 |
user_prompt = user_dislecxic(
|
| 306 |
story_details.get('target_age_group', '7-9'),
|
| 307 |
+
word_limit,
|
| 308 |
story_details.get('story_style', ''),
|
| 309 |
story_details.get('theme', ''),
|
| 310 |
story_details.get('language', 'English'),
|
|
|
|
| 355 |
try:
|
| 356 |
styled_prompts = []
|
| 357 |
style_descriptions = {
|
| 358 |
+
"Abstract Art": "Digital art in Abstract style with vibrant shapes and patterns, dynamic composition, non-representational elements, ",
|
| 359 |
+
"Art Deco": "Digital art in Art Deco style with symmetrical designs, bold geometric forms, radiant colors, 1920s aesthetic, ",
|
| 360 |
+
"Art Nouveau": "Digital illustration in Art Nouveau style with intricate floral motifs, curvilinear designs, flowing organic patterns, ",
|
| 361 |
+
"Bauhaus": "Digital art inspired by Bauhaus movement with geometric shapes, functional form, modernist approach, ",
|
| 362 |
+
"Celtic Art": "Digital art in Celtic style with intricate knotwork, spiral designs, medieval influence, ",
|
| 363 |
+
"Chinese Brush Painting": "Digital art in Chinese Brush Painting style with fluid brush strokes, serene composition, nature-inspired, ",
|
| 364 |
+
"Concept Art": "Detailed concept art illustration with rich details, atmospheric lighting, cinematic composition, ",
|
| 365 |
+
"Cyber Folk": "Digital art blending traditional folk patterns with futuristic cyber aesthetics, neon accents, ",
|
| 366 |
+
"Fairy Tale": "Classic storybook illustration with whimsical elements, soft colors, enchanted atmosphere, ",
|
| 367 |
+
"Fantasy": "Magical and imaginative digital art with ethereal lighting, fantastical elements, ",
|
| 368 |
+
"Pixar": "3D animated style with emotional depth, vibrant colors, expressive characters, cinematic quality, ",
|
| 369 |
+
"Watercolor": "Digital watercolor style with soft edges, flowing colors, artistic textures, delicate details, ",
|
| 370 |
+
"Abstract Geometry": "Digital art with clean geometric shapes, interlocking triangles and circles, modern minimal style, ",
|
| 371 |
+
"Bokeh Art": "Digital art with soft focus effects, luminous spots, dreamy atmosphere, ethereal lighting, ",
|
| 372 |
+
"Brutalism": "Digital art with raw textures, bold shapes, monolithic structures, stark contrasts, ",
|
| 373 |
+
"Byzantine": "Digital art with rich gold tones, mosaic-like textures, religious icon style, ornate details, ",
|
| 374 |
+
"Charcoal": "Digital art emulating charcoal drawing with bold strokes, rich textures, dramatic shadows, ",
|
| 375 |
+
"Chiptune": "Digital art in retro pixel art style, 8-bit aesthetic, vibrant colors, nostalgic gaming feel, "
|
| 376 |
}
|
| 377 |
|
| 378 |
style_prefix = style_descriptions.get(art_style, "Digital illustration in a ")
|
|
|
|
| 396 |
return None
|
| 397 |
|
| 398 |
# Main UI
|
| 399 |
+
st.title("✨ StoryMii")
|
| 400 |
|
| 401 |
# Sidebar navigation
|
| 402 |
page = st.sidebar.radio("Navigation", ["Create Story", "Story Library"])
|
|
|
|
| 455 |
|
| 456 |
story_details["target_age_group"] = st.select_slider(
|
| 457 |
"Target Age Group",
|
| 458 |
+
options=["1-3", "4-6", "7-9", "10-12"],
|
| 459 |
+
value="7-9",
|
| 460 |
+
help="Select the target age group for your story"
|
| 461 |
)
|
| 462 |
+
|
| 463 |
+
# Word limit based on age group
|
| 464 |
+
word_limits = {
|
| 465 |
+
"1-3": 50, # Simpler, shorter stories for toddlers
|
| 466 |
+
"4-6": 100, # Slightly longer for preschoolers
|
| 467 |
+
"7-9": 150, # More complex for early readers
|
| 468 |
+
"10-12": 200 # Longer stories for confident readers
|
| 469 |
+
}
|
| 470 |
+
word_limit = word_limits[story_details["target_age_group"]]
|
| 471 |
+
|
| 472 |
+
# Updated story tones
|
| 473 |
+
story_details["story_tone"] = st.selectbox(
|
| 474 |
+
"Story Tone",
|
| 475 |
+
["Whimsical", "Educational", "Neutral", "Gentle", "Encouraging"],
|
| 476 |
+
help="Choose the overall tone of your story"
|
| 477 |
+
)
|
| 478 |
+
|
| 479 |
+
# Updated story styles
|
| 480 |
+
story_details["story_style"] = st.radio(
|
| 481 |
+
"Story Style",
|
| 482 |
+
[
|
| 483 |
+
"Picture Book",
|
| 484 |
+
"Early Reader",
|
| 485 |
+
"Educational Story",
|
| 486 |
+
"Bedtime Story",
|
| 487 |
+
"Interactive Story",
|
| 488 |
+
"Simple Chapter Story"
|
| 489 |
+
],
|
| 490 |
+
help="Select the style that best fits your story"
|
| 491 |
+
)
|
| 492 |
+
|
| 493 |
+
story_details["main_character"] = st.text_input(
|
| 494 |
+
"Main Character",
|
| 495 |
+
help="Who is your story's protagonist?",
|
| 496 |
+
value=st.session_state.story_details.get("main_character", "")
|
| 497 |
+
)
|
| 498 |
+
suggest_character = st.form_submit_button("🦸 Suggest Character")
|
| 499 |
+
if suggest_character:
|
| 500 |
+
suggestion = get_ai_suggestion("main character")
|
| 501 |
+
if suggestion:
|
| 502 |
+
st.session_state.story_details["main_character"] = suggestion
|
| 503 |
+
story_details["main_character"] = suggestion
|
| 504 |
|
| 505 |
story_details["main_character_attributes"] = st.text_area(
|
| 506 |
"Character Attributes",
|