Update app.py
Browse files
app.py
CHANGED
|
@@ -56,7 +56,7 @@ INFERENCE_ENGINE = InferenceEngine(DEFAULT_MODEL_ARGS)
|
|
| 56 |
def infer(reference_image, audio_path, kps_sequence_save_path, output_path, retarget_strategy, reference_attention_weight, audio_attention_weight):
|
| 57 |
try:
|
| 58 |
logging.info("Starting inference")
|
| 59 |
-
global INFERENCE_ENGINE
|
| 60 |
INFERENCE_ENGINE.infer(
|
| 61 |
reference_image, audio_path, kps_sequence_save_path,
|
| 62 |
output_path,
|
|
@@ -69,18 +69,17 @@ def infer(reference_image, audio_path, kps_sequence_save_path, output_path, reta
|
|
| 69 |
logging.error(f"Inference failed: {e}")
|
| 70 |
return None, None
|
| 71 |
|
| 72 |
-
def process_video(args):
|
| 73 |
-
app, video, audio_path, kps_sequence_save_path = args
|
| 74 |
-
extract_kps_sequence_from_video(app, video, audio_path, kps_sequence_save_path)
|
| 75 |
-
return audio_path, kps_sequence_save_path
|
| 76 |
-
|
| 77 |
# Function to run V-Express demo
|
| 78 |
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()):
|
| 79 |
try:
|
| 80 |
# Step 1: Extract Keypoints from Video
|
| 81 |
progress((0,100), desc="Starting...")
|
| 82 |
logging.info("Demo started")
|
| 83 |
-
kps_sequence_save_path = f"{output_dir}/kps.pth"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
if video is not None:
|
| 85 |
# Run the script to extract keypoints and audio from the video
|
| 86 |
progress((25,100), desc="Extract keypoints and audio...")
|
|
|
|
| 56 |
def infer(reference_image, audio_path, kps_sequence_save_path, output_path, retarget_strategy, reference_attention_weight, audio_attention_weight):
|
| 57 |
try:
|
| 58 |
logging.info("Starting inference")
|
| 59 |
+
global INFERENCE_ENGINE
|
| 60 |
INFERENCE_ENGINE.infer(
|
| 61 |
reference_image, audio_path, kps_sequence_save_path,
|
| 62 |
output_path,
|
|
|
|
| 69 |
logging.error(f"Inference failed: {e}")
|
| 70 |
return None, None
|
| 71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
# Function to run V-Express demo
|
| 73 |
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()):
|
| 74 |
try:
|
| 75 |
# Step 1: Extract Keypoints from Video
|
| 76 |
progress((0,100), desc="Starting...")
|
| 77 |
logging.info("Demo started")
|
| 78 |
+
kps_sequence_save_path = f"{output_dir}/kps.pth"
|
| 79 |
+
# Check if output directory exists
|
| 80 |
+
if not os.path.exists(output_dir):
|
| 81 |
+
logging.info(f"Creating output directory: {output_dir}")
|
| 82 |
+
os.makedirs(output_dir)
|
| 83 |
if video is not None:
|
| 84 |
# Run the script to extract keypoints and audio from the video
|
| 85 |
progress((25,100), desc="Extract keypoints and audio...")
|