quantumos commited on
Commit
e79372a
·
verified ·
1 Parent(s): de93f47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -13
app.py CHANGED
@@ -2,10 +2,14 @@ import gradio as gr
2
  import shutil
3
  import subprocess
4
  import os
 
5
 
6
  from inference import InferenceEngine
7
  from sequence_utils import extract_kps_sequence_from_video
8
 
 
 
 
9
  output_dir = "output"
10
  temp_audio_path = "temp.mp3"
11
 
@@ -46,20 +50,24 @@ DEFAULT_MODEL_ARGS = {
46
  #'audio_attention_weight': 3.0
47
  }
48
 
 
49
  INFERENCE_ENGINE = InferenceEngine(DEFAULT_MODEL_ARGS)
50
 
51
- def infer(reference_image, audio_path, kps_sequence_save_path,
52
- output_path,
53
- retarget_strategy,
54
- reference_attention_weight, audio_attention_weight):
55
- global INFERENCE_ENGINE
56
- INFERENCE_ENGINE.infer(
57
- reference_image, audio_path, kps_sequence_save_path,
58
- output_path,
59
- retarget_strategy,
60
- reference_attention_weight, audio_attention_weight
61
- )
62
- return output_path, kps_sequence_save_path
 
 
 
63
 
64
  # Function to run V-Express demo
65
  def run_demo(
@@ -70,6 +78,7 @@ def run_demo(
70
  progress=gr.Progress()):
71
  # Step 1: Extract Keypoints from Video
72
  progress((0,100), desc="Starting...")
 
73
 
74
  kps_sequence_save_path = f"{output_dir}/kps.pth"
75
 
@@ -77,7 +86,7 @@ def run_demo(
77
  # Run the script to extract keypoints and audio from the video
78
  progress((25,100), desc="Extract keypoints and audio...")
79
  audio_path = video.replace(".mp4", ".mp3")
80
-
81
  extract_kps_sequence_from_video(
82
  INFERENCE_ENGINE.app,
83
  video,
 
2
  import shutil
3
  import subprocess
4
  import os
5
+ import logging
6
 
7
  from inference import InferenceEngine
8
  from sequence_utils import extract_kps_sequence_from_video
9
 
10
+ # Configure logging
11
+ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
12
+
13
  output_dir = "output"
14
  temp_audio_path = "temp.mp3"
15
 
 
50
  #'audio_attention_weight': 3.0
51
  }
52
 
53
+ logging.info("Initializing Inference Engine")
54
  INFERENCE_ENGINE = InferenceEngine(DEFAULT_MODEL_ARGS)
55
 
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,
63
+ retarget_strategy,
64
+ reference_attention_weight, audio_attention_weight
65
+ )
66
+ logging.info("Inference completed successfully")
67
+ return output_path, kps_sequence_save_path
68
+ except Exception as e:
69
+ logging.error(f"Inference failed: {e}")
70
+ return None, None
71
 
72
  # Function to run V-Express demo
73
  def run_demo(
 
78
  progress=gr.Progress()):
79
  # Step 1: Extract Keypoints from Video
80
  progress((0,100), desc="Starting...")
81
+ logging.info("Demo started")
82
 
83
  kps_sequence_save_path = f"{output_dir}/kps.pth"
84
 
 
86
  # Run the script to extract keypoints and audio from the video
87
  progress((25,100), desc="Extract keypoints and audio...")
88
  audio_path = video.replace(".mp4", ".mp3")
89
+ logging.info("Extracting keypoints and audio from video")
90
  extract_kps_sequence_from_video(
91
  INFERENCE_ENGINE.app,
92
  video,