Xuanyou commited on
Commit
3182286
Β·
verified Β·
1 Parent(s): 699dc3f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -79
app.py CHANGED
@@ -592,115 +592,86 @@ def process_video(video_file):
592
 
593
  # Custom CSS styling for the interface
594
  css = """
595
- body {
596
- font-family: 'Arial', sans-serif;
597
- background-color: #f5f5f5;
598
- color: #4a4a4a;
599
- }
600
  #title-container {
601
  font-family: 'Arial', sans-serif;
 
602
  text-align: center;
603
- margin-bottom: 30px;
604
  }
605
  #title-container h1 {
606
- font-size: 3em;
607
  font-weight: bold;
608
- color: #ff6f61;
609
- text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
610
  }
611
  #title-container h2 {
612
- font-size: 1.5em;
613
  color: #6c757d;
614
- margin-top: 10px;
615
- }
616
- .gr-tab {
617
- background-color: #ffffff;
618
- border: 1px solid #ddd;
619
- border-radius: 10px;
620
- box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
621
- padding: 20px;
622
  }
623
  #intro-text {
624
- font-size: 1.1em;
625
  color: #6c757d;
 
626
  text-align: center;
627
  font-style: italic;
628
- margin: 20px 0 40px;
629
  }
630
- button {
631
- background-color: #ff6f61;
632
- color: white;
633
- font-size: 1em;
634
- font-weight: bold;
635
- padding: 10px 20px;
636
- border: none;
637
  border-radius: 5px;
638
- cursor: pointer;
639
- }
640
- button:hover {
641
- background-color: #e55b4d;
642
- }
643
- .gr-row {
644
- margin-top: 20px;
645
  }
646
  """
647
 
648
  # Title and description
649
  title_html = """
650
  <div id="title-container">
651
- <h1>πŸ¦‹ Spirit Animal Generator</h1>
652
- <h2>Discover and visualize your unique spirit animal through AI!</h2>
653
  </div>
654
  """
655
 
656
  description_text = """
657
- ### 🌟 Welcome to the Spirit Animal Generator!
658
- This tool helps you transform videos and images into imaginative spirit animal creations using AI-powered technologies.
659
-
660
- #### πŸ›  Key Features:
661
- 1. **Video Transformation**: Convert driving videos into animated spirit animal visuals.
662
- 2. **Image Customization**: Generate artistic images of your spirit animal with customization options.
663
- 3. **AI-Powered Descriptions**: Descriptive prompts generated by OpenAI's GPT.
664
- 4. **High-Quality Outputs**: Stunning visuals powered by Stable Diffusion and ControlNet.
665
-
666
- #### πŸš€ How to Use:
667
- 1. **Upload Media**:
668
- - Videos: MP4 format for animations.
669
- - Images: Clear, high-resolution photos for better results.
670
  2. **Customize Options**:
671
- - Choose animal type and background preferences.
672
- 3. **Enjoy the Results**:
673
- - Videos: Transformed animations.
674
- - Images: Customized artwork with descriptive prompts.
675
-
676
- ✨ Let your imagination soar and find your spirit animal today! ✨
677
  ---
678
  """
679
 
680
- with gr.Blocks(css=css) as demo:
681
  gr.HTML(title_html)
682
- gr.Markdown(description_text, elem_id="intro-text")
683
 
684
  with gr.Tabs():
685
- with gr.Tab("🎨 Generate Spirit Animal Image"):
686
- gr.Markdown("Upload an image to generate a spirit animal representation.")
687
  with gr.Row():
688
  with gr.Column(scale=1):
689
- image_input = gr.Image(type="filepath", label="πŸ“· Upload an Image")
690
- animal_type = gr.Radio(
691
- choices=["Single Animal", "Multiple Animals"],
692
- label="🐾 Animal Type",
693
- value="Single Animal"
694
- )
695
- background_option = gr.Radio(
696
- choices=["Preserve Background", "Don't Preserve Background"],
697
- label="πŸŒ„ Background Option",
698
- value="Preserve Background"
699
- )
700
- generate_image_button = gr.Button("πŸ–Œ Generate Image")
701
  with gr.Column(scale=1):
702
- generated_prompt = gr.Textbox(label="✏️ Generated Prompt")
703
- generated_gallery = gr.Gallery(label="πŸ–Ό Generated Images")
704
 
705
  generate_image_button.click(
706
  fn=generate_spirit_animal,
@@ -708,14 +679,14 @@ with gr.Blocks(css=css) as demo:
708
  outputs=[generated_prompt, generated_gallery],
709
  )
710
 
711
- with gr.Tab("πŸŽ₯ Generate Spirit Animal Video"):
712
- gr.Markdown("Upload a driving video to generate a spirit animal animation.")
713
  with gr.Row():
714
  with gr.Column(scale=1):
715
- video_input = gr.Video(label="πŸŽ₯ Upload a Driving Video (MP4)")
716
- generate_video_button = gr.Button("πŸš€ Generate Video")
717
  with gr.Column(scale=1):
718
- video_output = gr.Video(label="🎞 Generated Spirit Animal Video")
719
 
720
  generate_video_button.click(
721
  fn=process_video,
@@ -723,4 +694,4 @@ with gr.Blocks(css=css) as demo:
723
  outputs=video_output,
724
  )
725
 
726
- demo.launch()
 
592
 
593
  # Custom CSS styling for the interface
594
  css = """
 
 
 
 
 
595
  #title-container {
596
  font-family: 'Arial', sans-serif;
597
+ color: #4a4a4a;
598
  text-align: center;
599
+ margin-bottom: 20px;
600
  }
601
  #title-container h1 {
602
+ font-size: 2.5em;
603
  font-weight: bold;
604
+ color: #ff9900;
 
605
  }
606
  #title-container h2 {
607
+ font-size: 1.2em;
608
  color: #6c757d;
 
 
 
 
 
 
 
 
609
  }
610
  #intro-text {
611
+ font-size: 1em;
612
  color: #6c757d;
613
+ margin: 50px;
614
  text-align: center;
615
  font-style: italic;
 
616
  }
617
+ #prompt-output {
618
+ font-family: 'Courier New', monospace;
619
+ color: #5a5a5a;
620
+ font-size: 1.1em;
621
+ padding: 10px;
622
+ background-color: #f9f9f9;
623
+ border: 1px solid #ddd;
624
  border-radius: 5px;
625
+ margin-top: 10px;
 
 
 
 
 
 
626
  }
627
  """
628
 
629
  # Title and description
630
  title_html = """
631
  <div id="title-container">
632
+ <h1>Spirit Animal Generator</h1>
633
+ <h2>Create your unique spirit animal with AI-assisted image generation.</h2>
634
  </div>
635
  """
636
 
637
  description_text = """
638
+ ### Project Overview
639
+ Welcome to the Spirit Animal Generator! This tool leverages advanced AI technologies to create unique visualizations of spirit animals from both videos and images.
640
+ #### Key Features:
641
+ 1. **Video Transformation**: Upload a driving video to generate a creative spirit animal animation.
642
+ 2. **Image Creation**: Upload an image and customize the spirit animal type and background options.
643
+ 3. **AI-Powered Prompting**: OpenAI's GPT generates descriptive prompts for each input.
644
+ 4. **High-Quality Outputs**: Generated using Stable Diffusion and ControlNet for stunning visuals.
645
+ ---
646
+ ### How It Works:
647
+ 1. **Upload Your Media**:
648
+ - Videos: Ensure the file is in MP4 format.
649
+ - Images: Use clear, high-resolution photos for better results.
 
650
  2. **Customize Options**:
651
+ - For images, select the type of animal and background settings.
652
+ 3. **View Your Results**:
653
+ - Videos will be transformed into animations.
654
+ - Images will produce customized visual art along with a generated prompt.
655
+ Discover your spirit animal and let your imagination run wild!
 
656
  ---
657
  """
658
 
659
+ with gr.Blocks() as demo:
660
  gr.HTML(title_html)
661
+ gr.Markdown(description_text)
662
 
663
  with gr.Tabs():
664
+ with gr.Tab("Generate Spirit Animal Image"):
665
+ gr.Markdown("Upload an image to generate a spirit animal.")
666
  with gr.Row():
667
  with gr.Column(scale=1):
668
+ image_input = gr.Image(type="filepath", label="Upload an image")
669
+ animal_type = gr.Radio(choices=["Single Animal", "Multiple Animals"], label="Animal Type", value="Single Animal")
670
+ background_option = gr.Radio(choices=["Preserve Background", "Don't Preserve Background"], label="Background Option", value="Preserve Background")
671
+ generate_image_button = gr.Button("Generate Image")
 
 
 
 
 
 
 
 
672
  with gr.Column(scale=1):
673
+ generated_prompt = gr.Textbox(label="Generated Prompt")
674
+ generated_gallery = gr.Gallery(label="Generated Images")
675
 
676
  generate_image_button.click(
677
  fn=generate_spirit_animal,
 
679
  outputs=[generated_prompt, generated_gallery],
680
  )
681
 
682
+ with gr.Tab("Generate Spirit Animal Video"):
683
+ gr.Markdown("Upload a driving video to generate a spirit animal video.")
684
  with gr.Row():
685
  with gr.Column(scale=1):
686
+ video_input = gr.Video(label="Upload a driving video (MP4 format)")
687
+ generate_video_button = gr.Button("Generate Video")
688
  with gr.Column(scale=1):
689
+ video_output = gr.Video(label="Generated Spirit Animal Video")
690
 
691
  generate_video_button.click(
692
  fn=process_video,
 
694
  outputs=video_output,
695
  )
696
 
697
+ demo.launch()