Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,9 @@ import logging
|
|
| 5 |
import os
|
| 6 |
import torch
|
| 7 |
from torch.multiprocessing import Pool, set_start_method
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
from inference import InferenceEngine
|
| 10 |
from sequence_utils import extract_kps_sequence_from_video
|
|
@@ -72,6 +75,17 @@ def process_video(args):
|
|
| 72 |
extract_kps_sequence_from_video(app, video, audio_path, kps_sequence_save_path)
|
| 73 |
return audio_path, kps_sequence_save_path
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
def run_demo(reference_image, audio, video, kps_path, output_path, retarget_strategy, reference_attention_weight=0.95, audio_attention_weight=3.0, progress=gr.Progress()):
|
| 76 |
try:
|
| 77 |
progress((0, 100), desc="Starting...")
|
|
@@ -158,6 +172,6 @@ output = [
|
|
| 158 |
title = "V-Express Gradio Interface"
|
| 159 |
description = "An interactive interface for generating talking face videos using V-Express."
|
| 160 |
|
| 161 |
-
demo = gr.Interface(run_demo, inputs, output, title=title, description=description)
|
| 162 |
-
|
| 163 |
demo.queue().launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 5 |
import os
|
| 6 |
import torch
|
| 7 |
from torch.multiprocessing import Pool, set_start_method
|
| 8 |
+
import cProfile
|
| 9 |
+
import pstats
|
| 10 |
+
import io
|
| 11 |
|
| 12 |
from inference import InferenceEngine
|
| 13 |
from sequence_utils import extract_kps_sequence_from_video
|
|
|
|
| 75 |
extract_kps_sequence_from_video(app, video, audio_path, kps_sequence_save_path)
|
| 76 |
return audio_path, kps_sequence_save_path
|
| 77 |
|
| 78 |
+
def profile_run_demo(*args, **kwargs):
|
| 79 |
+
pr = cProfile.Profile()
|
| 80 |
+
pr.enable()
|
| 81 |
+
result = run_demo(*args, **kwargs)
|
| 82 |
+
pr.disable()
|
| 83 |
+
s = io.StringIO()
|
| 84 |
+
ps = pstats.Stats(pr, stream=s).sort_stats('cumulative')
|
| 85 |
+
ps.print_stats()
|
| 86 |
+
print(s.getvalue())
|
| 87 |
+
return result
|
| 88 |
+
|
| 89 |
def run_demo(reference_image, audio, video, kps_path, output_path, retarget_strategy, reference_attention_weight=0.95, audio_attention_weight=3.0, progress=gr.Progress()):
|
| 90 |
try:
|
| 91 |
progress((0, 100), desc="Starting...")
|
|
|
|
| 172 |
title = "V-Express Gradio Interface"
|
| 173 |
description = "An interactive interface for generating talking face videos using V-Express."
|
| 174 |
|
| 175 |
+
#demo = gr.Interface(run_demo, inputs, output, title=title, description=description)
|
| 176 |
+
demo = gr.Interface(profile_run_demo, inputs, output, title=title, description=description)
|
| 177 |
demo.queue().launch(server_name="0.0.0.0", server_port=7860)
|