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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -7
app.py CHANGED
@@ -1,15 +1,26 @@
1
  import gradio as gr
2
  import subprocess
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",
12
- "--config_file", "./config/LS3DCG.json",
13
  "--infer",
14
  "--audio_file", audio_file,
15
  "--body_model_name", "s2g_LS3DCG",
@@ -23,10 +34,8 @@ def run_inference(audio_file):
23
  # Check for errors
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
 
1
  import gradio as gr
2
  import subprocess
3
  import os
4
+ import json
5
+
6
+ def get_log_name(config_file):
7
+ """Load the JSON configuration file to extract the log name."""
8
+ with open(config_file, 'r') as f:
9
+ config = json.load(f)
10
+ return config['Log']['name'] # Adjust this if the structure is different
11
 
12
  def run_inference(audio_file):
13
+ # Extract the audio filename
14
  audio_filename = os.path.basename(audio_file)
15
+
16
+ # Load the configuration to get the log name
17
+ config_file = './config/LS3DCG.json'
18
+ config_log_name = get_log_name(config_file)
19
+
20
  # Define the command to run your script
21
  command = [
22
  "python", "scripts/demo.py",
23
+ "--config_file", config_file,
24
  "--infer",
25
  "--audio_file", audio_file,
26
  "--body_model_name", "s2g_LS3DCG",
 
34
  # Check for errors
35
  if result.returncode != 0:
36
  return f"Error: {result.stderr}"
37
+
38
+ # Construct the output video filename based on the log name
 
 
39
  output_video_path = f'visualise/video/{config_log_name}/{audio_filename.rsplit(".", 1)[0]}.mp4'
40
 
41
  # Check if the video file exists and return the path