Spaces:
Running
on
Zero
Running
on
Zero
Use @spaces.GPU decorator for GPU management (reference LivePortrait)
Browse files- app.py +8 -1
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -7,6 +7,7 @@ import json
|
|
| 7 |
import warnings
|
| 8 |
from datetime import datetime
|
| 9 |
import gradio as gr
|
|
|
|
| 10 |
warnings.filterwarnings('ignore')
|
| 11 |
|
| 12 |
import random
|
|
@@ -572,6 +573,12 @@ def run_graio_demo(args):
|
|
| 572 |
logging.info("Finished.")
|
| 573 |
return output_file
|
| 574 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 575 |
def toggle_audio_inputs(person_num):
|
| 576 |
"""根据选择的人数显示对应数量的音频输入框"""
|
| 577 |
if person_num == "1 Person":
|
|
@@ -696,7 +703,7 @@ def run_graio_demo(args):
|
|
| 696 |
|
| 697 |
|
| 698 |
run_i2v_button.click(
|
| 699 |
-
fn=
|
| 700 |
inputs=[img2vid_image, img2vid_prompt, n_prompt, img2vid_audio_1, img2vid_audio_2, img2vid_audio_3, sd_steps, seed, guide_scale, person_num_selector, audio_mode_selector],
|
| 701 |
outputs=[result_gallery],
|
| 702 |
)
|
|
|
|
| 7 |
import warnings
|
| 8 |
from datetime import datetime
|
| 9 |
import gradio as gr
|
| 10 |
+
import spaces
|
| 11 |
warnings.filterwarnings('ignore')
|
| 12 |
|
| 13 |
import random
|
|
|
|
| 573 |
logging.info("Finished.")
|
| 574 |
return output_file
|
| 575 |
|
| 576 |
+
# 使用 @spaces.GPU 装饰器包装 generate_video 函数(参考 LivePortrait)
|
| 577 |
+
# 参考: https://huggingface.co/spaces/KlingTeam/LivePortrait/blob/main/app.py
|
| 578 |
+
@spaces.GPU(duration=240)
|
| 579 |
+
def gpu_wrapped_generate_video(*args, **kwargs):
|
| 580 |
+
return generate_video(*args, **kwargs)
|
| 581 |
+
|
| 582 |
def toggle_audio_inputs(person_num):
|
| 583 |
"""根据选择的人数显示对应数量的音频输入框"""
|
| 584 |
if person_num == "1 Person":
|
|
|
|
| 703 |
|
| 704 |
|
| 705 |
run_i2v_button.click(
|
| 706 |
+
fn=gpu_wrapped_generate_video, # 使用 GPU 包装函数
|
| 707 |
inputs=[img2vid_image, img2vid_prompt, n_prompt, img2vid_audio_1, img2vid_audio_2, img2vid_audio_3, sd_steps, seed, guide_scale, person_num_selector, audio_mode_selector],
|
| 708 |
outputs=[result_gallery],
|
| 709 |
)
|
requirements.txt
CHANGED
|
@@ -26,6 +26,7 @@ onnxruntime-gpu==1.22.0
|
|
| 26 |
insightface==0.7.3
|
| 27 |
transformers==4.52.0
|
| 28 |
huggingface_hub
|
|
|
|
| 29 |
ninja
|
| 30 |
# flash_attn 预编译 wheel (torch 2.6 + CUDA 12 + Python 3.10)
|
| 31 |
# 参考: https://huggingface.co/spaces/fffiloni/Meigen-MultiTalk/blob/main/requirements.txt
|
|
|
|
| 26 |
insightface==0.7.3
|
| 27 |
transformers==4.52.0
|
| 28 |
huggingface_hub
|
| 29 |
+
spaces
|
| 30 |
ninja
|
| 31 |
# flash_attn 预编译 wheel (torch 2.6 + CUDA 12 + Python 3.10)
|
| 32 |
# 参考: https://huggingface.co/spaces/fffiloni/Meigen-MultiTalk/blob/main/requirements.txt
|