Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -592,86 +592,115 @@ def process_video(video_file):
|
|
| 592 |
|
| 593 |
# Custom CSS styling for the interface
|
| 594 |
css = """
|
| 595 |
-
|
| 596 |
font-family: 'Arial', sans-serif;
|
|
|
|
| 597 |
color: #4a4a4a;
|
|
|
|
|
|
|
|
|
|
| 598 |
text-align: center;
|
| 599 |
-
margin-bottom:
|
| 600 |
}
|
| 601 |
#title-container h1 {
|
| 602 |
-
font-size:
|
| 603 |
font-weight: bold;
|
| 604 |
-
color: #
|
|
|
|
| 605 |
}
|
| 606 |
#title-container h2 {
|
| 607 |
-
font-size: 1.
|
| 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 |
-
|
| 618 |
-
|
| 619 |
-
color:
|
| 620 |
-
font-size:
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
border:
|
| 624 |
border-radius: 5px;
|
| 625 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 626 |
}
|
| 627 |
"""
|
| 628 |
|
| 629 |
# Title and description
|
| 630 |
title_html = """
|
| 631 |
<div id="title-container">
|
| 632 |
-
<h1
|
| 633 |
-
<h2>
|
| 634 |
</div>
|
| 635 |
"""
|
| 636 |
|
| 637 |
description_text = """
|
| 638 |
-
###
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
-
|
|
|
|
| 650 |
2. **Customize Options**:
|
| 651 |
-
-
|
| 652 |
-
3. **
|
| 653 |
-
- Videos
|
| 654 |
-
- Images
|
| 655 |
-
|
|
|
|
| 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
|
| 669 |
-
animal_type = gr.Radio(
|
| 670 |
-
|
| 671 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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,14 +708,14 @@ with gr.Blocks() as demo:
|
|
| 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
|
| 684 |
with gr.Row():
|
| 685 |
with gr.Column(scale=1):
|
| 686 |
-
video_input = gr.Video(label="Upload a
|
| 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,4 +723,4 @@ with gr.Blocks() as demo:
|
|
| 694 |
outputs=video_output,
|
| 695 |
)
|
| 696 |
|
| 697 |
-
demo.launch()
|
|
|
|
| 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 |
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 |
outputs=video_output,
|
| 724 |
)
|
| 725 |
|
| 726 |
+
demo.launch()
|