insanecoder69 commited on
Commit
7227d67
·
verified ·
1 Parent(s): 7c9a663

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -3,9 +3,9 @@ import subprocess
3
  import os
4
 
5
  def run_inference(audio_file):
6
- # Define the output video filename
7
- output_video = "output_video.mp4" # Change this to your desired output filename
8
-
9
  # Define the command to run your script
10
  command = [
11
  "python", "scripts/demo.py",
@@ -14,7 +14,7 @@ def run_inference(audio_file):
14
  "--audio_file", audio_file,
15
  "--body_model_name", "s2g_LS3DCG",
16
  "--body_model_path", "experiments/2022-10-19-smplx_S2G-LS3DCG/ckpt-99.pth",
17
- "--id", "0",
18
  ]
19
 
20
  # Run the command and capture the output
@@ -24,8 +24,16 @@ def run_inference(audio_file):
24
  if result.returncode != 0:
25
  return f"Error: {result.stderr}"
26
 
27
- # Return the generated video file path
28
- return output_video
 
 
 
 
 
 
 
 
29
 
30
  # Create Gradio interface
31
  interface = gr.Interface(
 
3
  import os
4
 
5
  def run_inference(audio_file):
6
+ # Extract the audio filename to construct the video filename later
7
+ audio_filename = os.path.basename(audio_file)
8
+
9
  # Define the command to run your script
10
  command = [
11
  "python", "scripts/demo.py",
 
14
  "--audio_file", audio_file,
15
  "--body_model_name", "s2g_LS3DCG",
16
  "--body_model_path", "experiments/2022-10-19-smplx_S2G-LS3DCG/ckpt-99.pth",
17
+ "--id", "0"
18
  ]
19
 
20
  # Run the command and capture the output
 
24
  if result.returncode != 0:
25
  return f"Error: {result.stderr}"
26
 
27
+ # Construct the output video filename based on your logic
28
+ # Assuming config.Log.name is a fixed string or you may need to adjust this accordingly
29
+ config_log_name = "YourLogName" # Replace with the actual log name used in your config
30
+ output_video_path = f'visualise/video/{config_log_name}/{audio_filename.rsplit(".", 1)[0]}.mp4'
31
+
32
+ # Check if the video file exists and return the path
33
+ if os.path.exists(output_video_path):
34
+ return output_video_path
35
+ else:
36
+ return "Video file not found."
37
 
38
  # Create Gradio interface
39
  interface = gr.Interface(