Spaces:
Running
Running
update to work on duplicated instàces only
Browse files
app.py
CHANGED
|
@@ -3,6 +3,11 @@ import random
|
|
| 3 |
from pathlib import Path
|
| 4 |
import numpy as np
|
| 5 |
import torch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
from diffusers import AutoencoderKL, DDIMScheduler
|
| 7 |
from PIL import Image
|
| 8 |
from src.models.unet_2d_condition import UNet2DConditionModel
|
|
@@ -314,8 +319,65 @@ def generate(image_input, audio_input, pose_input, width, height, length, steps,
|
|
| 314 |
seed_text = gr.update(visible=True, value=seed)
|
| 315 |
return video_output, seed_text
|
| 316 |
|
| 317 |
-
|
| 318 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
gr.Markdown("""
|
| 320 |
# EchoMimicV2
|
| 321 |
|
|
@@ -363,8 +425,50 @@ with gr.Blocks() as demo:
|
|
| 363 |
with gr.Row():
|
| 364 |
quantization_input = gr.Checkbox(label="Int8 Quantization (recommended for users with 12GB VRAM, use audio no longer than 5 seconds)", value=False)
|
| 365 |
seed = gr.Number(label="Seed (-1 for random)", value=-1)
|
| 366 |
-
generate_button = gr.Button("🎬 Generate Video")
|
| 367 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 368 |
video_output = gr.Video(label="Output Video")
|
| 369 |
seed_text = gr.Textbox(label="Seed", interactive=False, visible=False)
|
| 370 |
gr.Examples(
|
|
|
|
| 3 |
from pathlib import Path
|
| 4 |
import numpy as np
|
| 5 |
import torch
|
| 6 |
+
|
| 7 |
+
is_shared_ui = True if "fffiloni/echomimic-v2" in os.environ['SPACE_ID'] else False
|
| 8 |
+
is_gpu_associated = torch.cuda.is_available()
|
| 9 |
+
|
| 10 |
+
|
| 11 |
from diffusers import AutoencoderKL, DDIMScheduler
|
| 12 |
from PIL import Image
|
| 13 |
from src.models.unet_2d_condition import UNet2DConditionModel
|
|
|
|
| 319 |
seed_text = gr.update(visible=True, value=seed)
|
| 320 |
return video_output, seed_text
|
| 321 |
|
| 322 |
+
css = """
|
| 323 |
+
div#warning-duplicate {
|
| 324 |
+
background-color: #ebf5ff;
|
| 325 |
+
padding: 0 16px 16px;
|
| 326 |
+
margin: 20px 0;
|
| 327 |
+
color: #030303!important;
|
| 328 |
+
}
|
| 329 |
+
div#warning-duplicate > .gr-prose > h2, div#warning-duplicate > .gr-prose > p {
|
| 330 |
+
color: #0f4592!important;
|
| 331 |
+
}
|
| 332 |
+
div#warning-duplicate strong {
|
| 333 |
+
color: #0f4592;
|
| 334 |
+
}
|
| 335 |
+
p.actions {
|
| 336 |
+
display: flex;
|
| 337 |
+
align-items: center;
|
| 338 |
+
margin: 20px 0;
|
| 339 |
+
}
|
| 340 |
+
div#warning-duplicate .actions a {
|
| 341 |
+
display: inline-block;
|
| 342 |
+
margin-right: 10px;
|
| 343 |
+
}
|
| 344 |
+
div#warning-setgpu {
|
| 345 |
+
background-color: #fff4eb;
|
| 346 |
+
padding: 0 16px 16px;
|
| 347 |
+
margin: 20px 0;
|
| 348 |
+
color: #030303!important;
|
| 349 |
+
}
|
| 350 |
+
div#warning-setgpu > .gr-prose > h2, div#warning-setgpu > .gr-prose > p {
|
| 351 |
+
color: #92220f!important;
|
| 352 |
+
}
|
| 353 |
+
div#warning-setgpu a, div#warning-setgpu b {
|
| 354 |
+
color: #91230f;
|
| 355 |
+
}
|
| 356 |
+
div#warning-setgpu p.actions > a {
|
| 357 |
+
display: inline-block;
|
| 358 |
+
background: #1f1f23;
|
| 359 |
+
border-radius: 40px;
|
| 360 |
+
padding: 6px 24px;
|
| 361 |
+
color: antiquewhite;
|
| 362 |
+
text-decoration: none;
|
| 363 |
+
font-weight: 600;
|
| 364 |
+
font-size: 1.2em;
|
| 365 |
+
}
|
| 366 |
+
div#warning-ready {
|
| 367 |
+
background-color: #ecfdf5;
|
| 368 |
+
padding: 0 16px 16px;
|
| 369 |
+
margin: 20px 0;
|
| 370 |
+
color: #030303!important;
|
| 371 |
+
}
|
| 372 |
+
div#warning-ready > .gr-prose > h2, div#warning-ready > .gr-prose > p {
|
| 373 |
+
color: #057857!important;
|
| 374 |
+
}
|
| 375 |
+
.custom-color {
|
| 376 |
+
color: #030303 !important;
|
| 377 |
+
}
|
| 378 |
+
"""
|
| 379 |
+
|
| 380 |
+
with gr.Blocks(css=css) as demo:
|
| 381 |
gr.Markdown("""
|
| 382 |
# EchoMimicV2
|
| 383 |
|
|
|
|
| 425 |
with gr.Row():
|
| 426 |
quantization_input = gr.Checkbox(label="Int8 Quantization (recommended for users with 12GB VRAM, use audio no longer than 5 seconds)", value=False)
|
| 427 |
seed = gr.Number(label="Seed (-1 for random)", value=-1)
|
| 428 |
+
generate_button = gr.Button("🎬 Generate Video", interactive=False if is_shared_ui else True)
|
| 429 |
with gr.Column():
|
| 430 |
+
|
| 431 |
+
if is_shared_ui:
|
| 432 |
+
top_description = gr.HTML(f'''
|
| 433 |
+
<div class="gr-prose">
|
| 434 |
+
<h2 class="custom-color"><svg xmlns="http://www.w3.org/2000/svg" width="18px" height="18px" style="margin-right: 0px;display: inline-block;"fill="none"><path fill="#fff" d="M7 13.2a6.3 6.3 0 0 0 4.4-10.7A6.3 6.3 0 0 0 .6 6.9 6.3 6.3 0 0 0 7 13.2Z"/><path fill="#fff" fill-rule="evenodd" d="M7 0a6.9 6.9 0 0 1 4.8 11.8A6.9 6.9 0 0 1 0 7 6.9 6.9 0 0 1 7 0Zm0 0v.7V0ZM0 7h.6H0Zm7 6.8v-.6.6ZM13.7 7h-.6.6ZM9.1 1.7c-.7-.3-1.4-.4-2.2-.4a5.6 5.6 0 0 0-4 1.6 5.6 5.6 0 0 0-1.6 4 5.6 5.6 0 0 0 1.6 4 5.6 5.6 0 0 0 4 1.7 5.6 5.6 0 0 0 4-1.7 5.6 5.6 0 0 0 1.7-4 5.6 5.6 0 0 0-1.7-4c-.5-.5-1.1-.9-1.8-1.2Z" clip-rule="evenodd"/><path fill="#000" fill-rule="evenodd" d="M7 2.9a.8.8 0 1 1 0 1.5A.8.8 0 0 1 7 3ZM5.8 5.7c0-.4.3-.6.6-.6h.7c.3 0 .6.2.6.6v3.7h.5a.6.6 0 0 1 0 1.3H6a.6.6 0 0 1 0-1.3h.4v-3a.6.6 0 0 1-.6-.7Z" clip-rule="evenodd"/></svg>
|
| 435 |
+
Attention: this Space need to be duplicated to work</h2>
|
| 436 |
+
<p class="main-message custom-color">
|
| 437 |
+
To make it work, <strong>duplicate the Space</strong> and run it on your own profile using a <strong>private</strong> GPU (L40s recommended).<br />
|
| 438 |
+
A L40s costs <strong>US$1.80/h</strong>.
|
| 439 |
+
</p>
|
| 440 |
+
<p class="actions custom-color">
|
| 441 |
+
<a href="https://huggingface.co/spaces/{os.environ['SPACE_ID']}?duplicate=true">
|
| 442 |
+
<img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-lg-dark.svg" alt="Duplicate this Space" />
|
| 443 |
+
</a>
|
| 444 |
+
to start experimenting with this demo
|
| 445 |
+
</p>
|
| 446 |
+
</div>
|
| 447 |
+
''', elem_id="warning-duplicate")
|
| 448 |
+
else:
|
| 449 |
+
if(is_gpu_associated):
|
| 450 |
+
top_description = gr.HTML(f'''
|
| 451 |
+
<div class="gr-prose">
|
| 452 |
+
<h2 class="custom-color"><svg xmlns="http://www.w3.org/2000/svg" width="18px" height="18px" style="margin-right: 0px;display: inline-block;"fill="none"><path fill="#fff" d="M7 13.2a6.3 6.3 0 0 0 4.4-10.7A6.3 6.3 0 0 0 .6 6.9 6.3 6.3 0 0 0 7 13.2Z"/><path fill="#fff" fill-rule="evenodd" d="M7 0a6.9 6.9 0 0 1 4.8 11.8A6.9 6.9 0 0 1 0 7 6.9 6.9 0 0 1 7 0Zm0 0v.7V0ZM0 7h.6H0Zm7 6.8v-.6.6ZM13.7 7h-.6.6ZM9.1 1.7c-.7-.3-1.4-.4-2.2-.4a5.6 5.6 0 0 0-4 1.6 5.6 5.6 0 0 0-1.6 4 5.6 5.6 0 0 0 1.6 4 5.6 5.6 0 0 0 4 1.7 5.6 5.6 0 0 0 4-1.7 5.6 5.6 0 0 0 1.7-4 5.6 5.6 0 0 0-1.7-4c-.5-.5-1.1-.9-1.8-1.2Z" clip-rule="evenodd"/><path fill="#000" fill-rule="evenodd" d="M7 2.9a.8.8 0 1 1 0 1.5A.8.8 0 0 1 7 3ZM5.8 5.7c0-.4.3-.6.6-.6h.7c.3 0 .6.2.6.6v3.7h.5a.6.6 0 0 1 0 1.3H6a.6.6 0 0 1 0-1.3h.4v-3a.6.6 0 0 1-.6-.7Z" clip-rule="evenodd"/></svg>
|
| 453 |
+
You have successfully associated a GPU to this Space 🎉</h2>
|
| 454 |
+
<p class="custom-color">
|
| 455 |
+
You will be billed by the minute from when you activated the GPU until when it is turned off.
|
| 456 |
+
</p>
|
| 457 |
+
</div>
|
| 458 |
+
''', elem_id="warning-ready")
|
| 459 |
+
else:
|
| 460 |
+
top_description = gr.HTML(f'''
|
| 461 |
+
<div class="gr-prose">
|
| 462 |
+
<h2 class="custom-color"><svg xmlns="http://www.w3.org/2000/svg" width="18px" height="18px" style="margin-right: 0px;display: inline-block;"fill="none"><path fill="#fff" d="M7 13.2a6.3 6.3 0 0 0 4.4-10.7A6.3 6.3 0 0 0 .6 6.9 6.3 6.3 0 0 0 7 13.2Z"/><path fill="#fff" fill-rule="evenodd" d="M7 0a6.9 6.9 0 0 1 4.8 11.8A6.9 6.9 0 0 1 0 7 6.9 6.9 0 0 1 7 0Zm0 0v.7V0ZM0 7h.6H0Zm7 6.8v-.6.6ZM13.7 7h-.6.6ZM9.1 1.7c-.7-.3-1.4-.4-2.2-.4a5.6 5.6 0 0 0-4 1.6 5.6 5.6 0 0 0-1.6 4 5.6 5.6 0 0 0 1.6 4 5.6 5.6 0 0 0 4 1.7 5.6 5.6 0 0 0 4-1.7 5.6 5.6 0 0 0 1.7-4 5.6 5.6 0 0 0-1.7-4c-.5-.5-1.1-.9-1.8-1.2Z" clip-rule="evenodd"/><path fill="#000" fill-rule="evenodd" d="M7 2.9a.8.8 0 1 1 0 1.5A.8.8 0 0 1 7 3ZM5.8 5.7c0-.4.3-.6.6-.6h.7c.3 0 .6.2.6.6v3.7h.5a.6.6 0 0 1 0 1.3H6a.6.6 0 0 1 0-1.3h.4v-3a.6.6 0 0 1-.6-.7Z" clip-rule="evenodd"/></svg>
|
| 463 |
+
You have successfully duplicated the MimicMotion Space 🎉</h2>
|
| 464 |
+
<p class="custom-color">There's only one step left before you can properly play with this demo: <a href="https://huggingface.co/spaces/{os.environ['SPACE_ID']}/settings" style="text-decoration: underline" target="_blank">attribute a GPU</b> to it (via the Settings tab)</a> and run the app below.
|
| 465 |
+
You will be billed by the minute from when you activate the GPU until when it is turned off.</p>
|
| 466 |
+
<p class="actions custom-color">
|
| 467 |
+
<a href="https://huggingface.co/spaces/{os.environ['SPACE_ID']}/settings">🔥 Set recommended GPU</a>
|
| 468 |
+
</p>
|
| 469 |
+
</div>
|
| 470 |
+
''', elem_id="warning-setgpu")
|
| 471 |
+
|
| 472 |
video_output = gr.Video(label="Output Video")
|
| 473 |
seed_text = gr.Textbox(label="Seed", interactive=False, visible=False)
|
| 474 |
gr.Examples(
|