Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
@@ -1,58 +0,0 @@
|
|
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",
|
27 |
-
"--body_model_path", "experiments/2022-10-19-smplx_S2G-LS3DCG/ckpt-99.pth",
|
28 |
-
"--id", "0"
|
29 |
-
]
|
30 |
-
|
31 |
-
# Run the command and capture the output
|
32 |
-
result = subprocess.run(command, capture_output=True, text=True)
|
33 |
-
|
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
|
42 |
-
if os.path.exists(output_video_path):
|
43 |
-
return output_video_path
|
44 |
-
else:
|
45 |
-
return "Video file not found."
|
46 |
-
|
47 |
-
# Create Gradio interface
|
48 |
-
interface = gr.Interface(
|
49 |
-
fn=run_inference,
|
50 |
-
inputs=gr.Audio(source="upload", type="filepath"),
|
51 |
-
outputs=gr.Video(type="file"),
|
52 |
-
title="Audio to Video Inference",
|
53 |
-
description="Upload an audio file to generate a video."
|
54 |
-
)
|
55 |
-
|
56 |
-
# Launch the app
|
57 |
-
if __name__ == "__main__":
|
58 |
-
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|