Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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:
|
604 |
}
|
605 |
#title-container h1 {
|
606 |
-
font-size:
|
607 |
font-weight: bold;
|
608 |
-
color: #
|
609 |
-
text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
|
610 |
}
|
611 |
#title-container h2 {
|
612 |
-
font-size: 1.
|
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:
|
625 |
color: #6c757d;
|
|
|
626 |
text-align: center;
|
627 |
font-style: italic;
|
628 |
-
margin: 20px 0 40px;
|
629 |
}
|
630 |
-
|
631 |
-
|
632 |
-
color:
|
633 |
-
font-size: 1em;
|
634 |
-
|
635 |
-
|
636 |
-
border:
|
637 |
border-radius: 5px;
|
638 |
-
|
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
|
652 |
-
<h2>
|
653 |
</div>
|
654 |
"""
|
655 |
|
656 |
description_text = """
|
657 |
-
###
|
658 |
-
This tool
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
-
|
669 |
-
- Images: Clear, high-resolution photos for better results.
|
670 |
2. **Customize Options**:
|
671 |
-
-
|
672 |
-
3. **
|
673 |
-
- Videos
|
674 |
-
- Images
|
675 |
-
|
676 |
-
β¨ Let your imagination soar and find your spirit animal today! β¨
|
677 |
---
|
678 |
"""
|
679 |
|
680 |
-
with gr.Blocks(
|
681 |
gr.HTML(title_html)
|
682 |
-
gr.Markdown(description_text
|
683 |
|
684 |
with gr.Tabs():
|
685 |
-
with gr.Tab("
|
686 |
-
gr.Markdown("Upload an image to generate a spirit animal
|
687 |
with gr.Row():
|
688 |
with gr.Column(scale=1):
|
689 |
-
image_input = gr.Image(type="filepath", label="
|
690 |
-
animal_type = gr.Radio(
|
691 |
-
|
692 |
-
|
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="
|
703 |
-
generated_gallery = gr.Gallery(label="
|
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("
|
712 |
-
gr.Markdown("Upload a driving video to generate a spirit animal
|
713 |
with gr.Row():
|
714 |
with gr.Column(scale=1):
|
715 |
-
video_input = gr.Video(label="
|
716 |
-
generate_video_button = gr.Button("
|
717 |
with gr.Column(scale=1):
|
718 |
-
video_output = gr.Video(label="
|
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()
|