quantumos commited on
Commit
1275ef7
·
verified ·
1 Parent(s): 2a38b46

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -40
app.py CHANGED
@@ -1,11 +1,8 @@
1
- """import gradio as gr
2
  import shutil
3
  import subprocess
4
  import logging
5
  import os
6
- import cProfile
7
- import pstats
8
- import io
9
 
10
  from inference import InferenceEngine
11
  from sequence_utils import extract_kps_sequence_from_video
@@ -68,17 +65,6 @@ def process_video(args):
68
  extract_kps_sequence_from_video(app, video, audio_path, kps_sequence_save_path)
69
  return audio_path, kps_sequence_save_path
70
 
71
- def profile_run_demo(*args, **kwargs):
72
- pr = cProfile.Profile()
73
- pr.enable()
74
- result = run_demo(*args, **kwargs)
75
- pr.disable()
76
- s = io.StringIO()
77
- ps = pstats.Stats(pr, stream=s).sort_stats('cumulative')
78
- ps.print_stats()
79
- print(s.getvalue())
80
- return result
81
-
82
  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()):
83
  try:
84
  progress((0, 100), desc="Starting...")
@@ -142,32 +128,8 @@ output = [
142
  title = "V-Express Gradio Interface"
143
  description = "An interactive interface for generating talking face videos using V-Express."
144
 
145
- #demo = gr.Interface(run_demo, inputs, output, title=title, description=description)
146
- demo = gr.Interface(profile_run_demo, inputs, output, title=title, description=description)
147
  demo.queue().launch(server_name="0.0.0.0", server_port=7860)
148
- """
149
 
150
- import subprocess
151
- import os
152
 
153
- def setup_and_run():
154
- try:
155
- # Run the setup script
156
- subprocess.run(['bash', 'setup.sh'], check=True)
157
-
158
- # Change the working directory to V-Express
159
- os.chdir('V-Express')
160
-
161
- # Run the extract_kps_sequence_and_audio.py script from within the V-Express directory
162
- result = subprocess.run(['python', 'extract_kps_sequence_and_audio.py'], capture_output=True, text=True)
163
-
164
- # Change back to the original working directory
165
- os.chdir('..')
166
-
167
- return result.stdout + "\n" + result.stderr
168
- except subprocess.CalledProcessError as e:
169
- return f"An error occurred: {e}\n{e.output}"
170
 
171
- if __name__ == "__main__":
172
- output = setup_and_run()
173
- print(output)
 
1
+ import gradio as gr
2
  import shutil
3
  import subprocess
4
  import logging
5
  import os
 
 
 
6
 
7
  from inference import InferenceEngine
8
  from sequence_utils import extract_kps_sequence_from_video
 
65
  extract_kps_sequence_from_video(app, video, audio_path, kps_sequence_save_path)
66
  return audio_path, kps_sequence_save_path
67
 
 
 
 
 
 
 
 
 
 
 
 
68
  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()):
69
  try:
70
  progress((0, 100), desc="Starting...")
 
128
  title = "V-Express Gradio Interface"
129
  description = "An interactive interface for generating talking face videos using V-Express."
130
 
131
+ demo = gr.Interface(run_demo, inputs, output, title=title, description=description)
 
132
  demo.queue().launch(server_name="0.0.0.0", server_port=7860)
 
133
 
 
 
134
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135