Prof-Hunt commited on
Commit
8dba140
Β·
verified Β·
1 Parent(s): 7d77471

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +98 -100
app.py CHANGED
@@ -602,7 +602,6 @@ def process_generated_prompt(prompt, paragraph):
602
 
603
  return prompt
604
 
605
- # Create the interface
606
  def create_interface():
607
  # Define CSS for custom styling
608
  css = """
@@ -658,101 +657,101 @@ def create_interface():
658
 
659
  # Step 1: Generate Landscape
660
  with gr.Row(elem_classes="section-content"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
661
  with gr.Column():
662
- with gr.Box(elem_classes="ai-lesson"):
663
- gr.Markdown("""
664
- ### Step 1: Setting the Scene with AI πŸ–ΌοΈ
665
-
666
- πŸ€– **AI Lesson: Text-to-Image Generation**
667
- We're using Stable Diffusion, a powerful AI model that turns text into images.
668
- How it works:
669
- - Starts with random noise and gradually refines it into an image
670
- - Uses millions of image-text pairs from its training
671
- - Combines understanding of both language and visual elements
672
- - Takes about 50 steps to create each image
673
-
674
- Real-world applications: Book illustrations, concept art, product visualization
675
- """)
676
  generate_btn = gr.Button("1. Generate Random Landscape", elem_classes="custom-button")
677
  image_output = gr.Image(label="Your AI-Generated Landscape", type="pil", interactive=False)
678
 
679
  # Step 2: Analyze Scene
680
  with gr.Row(elem_classes="section-content"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
681
  with gr.Column():
682
- with gr.Box(elem_classes="ai-lesson"):
683
- gr.Markdown("""
684
- ### Step 2: Teaching AI to See πŸ‘οΈ
685
-
686
- πŸ€– **AI Lesson: Vision-Language Models (VLM)**
687
- Our VLM acts like an AI art critic, understanding and describing images.
688
- How it works:
689
- - Processes images through neural networks
690
- - Identifies objects, scenes, colors, and relationships
691
- - Translates visual features into natural language
692
- - Uses attention mechanisms to focus on important details
693
-
694
- Real-world applications: Image search, accessibility tools, medical imaging
695
- """)
696
  analyze_btn = gr.Button("2. Get Brief Description", elem_classes="custom-button")
697
  analysis_output = gr.Textbox(label="What the AI Sees", lines=3)
698
 
699
  # Step 3: Create Story
700
  with gr.Row(elem_classes="section-content"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
701
  with gr.Column():
702
- with gr.Box(elem_classes="ai-lesson"):
703
- gr.Markdown("""
704
- ### Step 3: Crafting the Narrative πŸ“–
705
-
706
- πŸ€– **AI Lesson: Large Language Models**
707
- Meet our AI storyteller! It uses a Large Language Model (LLM) to write creative stories.
708
- How it works:
709
- - Processes the scene description as context
710
- - Uses pattern recognition from millions of stories
711
- - Maintains narrative consistency and character development
712
- - Adapts its writing style for children
713
-
714
- Real-world applications: Content creation, creative writing, education
715
- """)
716
  story_btn = gr.Button("3. Create Children's Story", elem_classes="custom-button")
717
  story_output = gr.Textbox(label="Your AI-Generated Story", lines=10)
718
 
719
  # Step 4: Generate Prompts
720
  with gr.Row(elem_classes="section-content"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
721
  with gr.Column():
722
- with gr.Box(elem_classes="ai-lesson"):
723
- gr.Markdown("""
724
- ### Step 4: Planning the Illustrations 🎯
725
-
726
- πŸ€– **AI Lesson: Natural Language Processing**
727
- The AI breaks down the story into key scenes and creates optimal image prompts.
728
- How it works:
729
- - Analyzes story structure and pacing
730
- - Identifies key narrative moments
731
- - Generates specialized prompts for each scene
732
- - Ensures visual consistency across illustrations
733
-
734
- Real-world applications: Content planning, storyboarding, scene composition
735
- """)
736
  prompts_btn = gr.Button("4. Generate Scene Prompts", elem_classes="custom-button")
737
  prompts_output = gr.Textbox(label="Scene Descriptions", lines=20)
738
 
739
  # Step 5: Generate Scenes
740
  with gr.Row(elem_classes="section-content"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
741
  with gr.Column():
742
- with gr.Box(elem_classes="ai-lesson"):
743
- gr.Markdown("""
744
- ### Step 5: Bringing Scenes to Life 🎨
745
-
746
- πŸ€– **AI Lesson: Specialized Image Generation**
747
- Using a fine-tuned model to create consistent character illustrations.
748
- How it works:
749
- - Uses LoRA (Low-Rank Adaptation) for specialized training
750
- - Maintains consistent character appearance
751
- - Processes multiple scenes in parallel
752
- - Balances creativity with prompt adherence
753
-
754
- Real-world applications: Character design, animation, book illustration
755
- """)
756
  generate_scenes_btn = gr.Button("5. Generate Story Scenes", elem_classes="custom-button")
757
  scene_progress = gr.Textbox(label="Generation Progress", lines=6, interactive=False)
758
  gallery = gr.Gallery(label="Story Scenes", columns=2, height="auto", interactive=False)
@@ -760,42 +759,42 @@ def create_interface():
760
 
761
  # Step 6: Add Text
762
  with gr.Row(elem_classes="section-content"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
763
  with gr.Column():
764
- with gr.Box(elem_classes="ai-lesson"):
765
- gr.Markdown("""
766
- ### Step 6: Creating Book Pages πŸ“š
767
-
768
- πŸ€– **AI Lesson: Computer Vision & Layout**
769
- Combining images and text requires sophisticated layout algorithms.
770
- How it works:
771
- - Analyzes image composition for text placement
772
- - Adjusts font size and style for readability
773
- - Creates visual hierarchy between elements
774
- - Ensures consistent formatting across pages
775
-
776
- Real-world applications: Desktop publishing, web design, digital books
777
- """)
778
  add_text_btn = gr.Button("6. Add Text to Scenes", elem_classes="custom-button")
779
  final_gallery = gr.Gallery(label="Final Book Pages", columns=2, height="auto", interactive=False)
780
  download_btn = gr.File(label="Download Your Story Book", file_count="multiple", interactive=False)
781
 
782
  # Step 7: Audio Generation
783
  with gr.Row(elem_classes="section-content"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
784
  with gr.Column():
785
- with gr.Box(elem_classes="ai-lesson"):
786
- gr.Markdown("""
787
- ### Step 7: Adding Narration 🎧
788
-
789
- πŸ€– **AI Lesson: Text-to-Speech Synthesis**
790
- Converting our story into natural-sounding speech.
791
- How it works:
792
- - Uses neural networks for voice synthesis
793
- - Adds appropriate emotion and emphasis
794
- - Controls pacing and pronunciation
795
- - Maintains consistent voice throughout
796
-
797
- Real-world applications: Audiobooks, accessibility tools, virtual assistants
798
- """)
799
  tts_btn = gr.Button("7. Read Story Aloud", elem_classes="custom-button")
800
  audio_output = gr.Audio(label="Story Narration")
801
 
@@ -817,7 +816,6 @@ def create_interface():
817
  tts_btn.click(fn=generate_combined_audio_from_story, inputs=[story_output], outputs=audio_output)
818
 
819
  return demo
820
-
821
  if __name__ == "__main__":
822
  demo = create_interface()
823
  demo.launch()
 
602
 
603
  return prompt
604
 
 
605
  def create_interface():
606
  # Define CSS for custom styling
607
  css = """
 
657
 
658
  # Step 1: Generate Landscape
659
  with gr.Row(elem_classes="section-content"):
660
+ with gr.Column(elem_classes="ai-lesson"):
661
+ gr.Markdown("""
662
+ ### Step 1: Setting the Scene with AI πŸ–ΌοΈ
663
+
664
+ πŸ€– **AI Lesson: Text-to-Image Generation**
665
+ We're using Stable Diffusion, a powerful AI model that turns text into images.
666
+ How it works:
667
+ - Starts with random noise and gradually refines it into an image
668
+ - Uses millions of image-text pairs from its training
669
+ - Combines understanding of both language and visual elements
670
+ - Takes about 50 steps to create each image
671
+
672
+ Real-world applications: Book illustrations, concept art, product visualization
673
+ """)
674
  with gr.Column():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
675
  generate_btn = gr.Button("1. Generate Random Landscape", elem_classes="custom-button")
676
  image_output = gr.Image(label="Your AI-Generated Landscape", type="pil", interactive=False)
677
 
678
  # Step 2: Analyze Scene
679
  with gr.Row(elem_classes="section-content"):
680
+ with gr.Column(elem_classes="ai-lesson"):
681
+ gr.Markdown("""
682
+ ### Step 2: Teaching AI to See πŸ‘οΈ
683
+
684
+ πŸ€– **AI Lesson: Vision-Language Models (VLM)**
685
+ Our VLM acts like an AI art critic, understanding and describing images.
686
+ How it works:
687
+ - Processes images through neural networks
688
+ - Identifies objects, scenes, colors, and relationships
689
+ - Translates visual features into natural language
690
+ - Uses attention mechanisms to focus on important details
691
+
692
+ Real-world applications: Image search, accessibility tools, medical imaging
693
+ """)
694
  with gr.Column():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
695
  analyze_btn = gr.Button("2. Get Brief Description", elem_classes="custom-button")
696
  analysis_output = gr.Textbox(label="What the AI Sees", lines=3)
697
 
698
  # Step 3: Create Story
699
  with gr.Row(elem_classes="section-content"):
700
+ with gr.Column(elem_classes="ai-lesson"):
701
+ gr.Markdown("""
702
+ ### Step 3: Crafting the Narrative πŸ“–
703
+
704
+ πŸ€– **AI Lesson: Large Language Models**
705
+ Meet our AI storyteller! It uses a Large Language Model (LLM) to write creative stories.
706
+ How it works:
707
+ - Processes the scene description as context
708
+ - Uses pattern recognition from millions of stories
709
+ - Maintains narrative consistency and character development
710
+ - Adapts its writing style for children
711
+
712
+ Real-world applications: Content creation, creative writing, education
713
+ """)
714
  with gr.Column():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
715
  story_btn = gr.Button("3. Create Children's Story", elem_classes="custom-button")
716
  story_output = gr.Textbox(label="Your AI-Generated Story", lines=10)
717
 
718
  # Step 4: Generate Prompts
719
  with gr.Row(elem_classes="section-content"):
720
+ with gr.Column(elem_classes="ai-lesson"):
721
+ gr.Markdown("""
722
+ ### Step 4: Planning the Illustrations 🎯
723
+
724
+ πŸ€– **AI Lesson: Natural Language Processing**
725
+ The AI breaks down the story into key scenes and creates optimal image prompts.
726
+ How it works:
727
+ - Analyzes story structure and pacing
728
+ - Identifies key narrative moments
729
+ - Generates specialized prompts for each scene
730
+ - Ensures visual consistency across illustrations
731
+
732
+ Real-world applications: Content planning, storyboarding, scene composition
733
+ """)
734
  with gr.Column():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
735
  prompts_btn = gr.Button("4. Generate Scene Prompts", elem_classes="custom-button")
736
  prompts_output = gr.Textbox(label="Scene Descriptions", lines=20)
737
 
738
  # Step 5: Generate Scenes
739
  with gr.Row(elem_classes="section-content"):
740
+ with gr.Column(elem_classes="ai-lesson"):
741
+ gr.Markdown("""
742
+ ### Step 5: Bringing Scenes to Life 🎨
743
+
744
+ πŸ€– **AI Lesson: Specialized Image Generation**
745
+ Using a fine-tuned model to create consistent character illustrations.
746
+ How it works:
747
+ - Uses LoRA (Low-Rank Adaptation) for specialized training
748
+ - Maintains consistent character appearance
749
+ - Processes multiple scenes in parallel
750
+ - Balances creativity with prompt adherence
751
+
752
+ Real-world applications: Character design, animation, book illustration
753
+ """)
754
  with gr.Column():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
755
  generate_scenes_btn = gr.Button("5. Generate Story Scenes", elem_classes="custom-button")
756
  scene_progress = gr.Textbox(label="Generation Progress", lines=6, interactive=False)
757
  gallery = gr.Gallery(label="Story Scenes", columns=2, height="auto", interactive=False)
 
759
 
760
  # Step 6: Add Text
761
  with gr.Row(elem_classes="section-content"):
762
+ with gr.Column(elem_classes="ai-lesson"):
763
+ gr.Markdown("""
764
+ ### Step 6: Creating Book Pages πŸ“š
765
+
766
+ πŸ€– **AI Lesson: Computer Vision & Layout**
767
+ Combining images and text requires sophisticated layout algorithms.
768
+ How it works:
769
+ - Analyzes image composition for text placement
770
+ - Adjusts font size and style for readability
771
+ - Creates visual hierarchy between elements
772
+ - Ensures consistent formatting across pages
773
+
774
+ Real-world applications: Desktop publishing, web design, digital books
775
+ """)
776
  with gr.Column():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
777
  add_text_btn = gr.Button("6. Add Text to Scenes", elem_classes="custom-button")
778
  final_gallery = gr.Gallery(label="Final Book Pages", columns=2, height="auto", interactive=False)
779
  download_btn = gr.File(label="Download Your Story Book", file_count="multiple", interactive=False)
780
 
781
  # Step 7: Audio Generation
782
  with gr.Row(elem_classes="section-content"):
783
+ with gr.Column(elem_classes="ai-lesson"):
784
+ gr.Markdown("""
785
+ ### Step 7: Adding Narration 🎧
786
+
787
+ πŸ€– **AI Lesson: Text-to-Speech Synthesis**
788
+ Converting our story into natural-sounding speech.
789
+ How it works:
790
+ - Uses neural networks for voice synthesis
791
+ - Adds appropriate emotion and emphasis
792
+ - Controls pacing and pronunciation
793
+ - Maintains consistent voice throughout
794
+
795
+ Real-world applications: Audiobooks, accessibility tools, virtual assistants
796
+ """)
797
  with gr.Column():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
798
  tts_btn = gr.Button("7. Read Story Aloud", elem_classes="custom-button")
799
  audio_output = gr.Audio(label="Story Narration")
800
 
 
816
  tts_btn.click(fn=generate_combined_audio_from_story, inputs=[story_output], outputs=audio_output)
817
 
818
  return demo
 
819
  if __name__ == "__main__":
820
  demo = create_interface()
821
  demo.launch()