Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,42 @@
|
|
1 |
-
import
|
2 |
-
import
|
3 |
-
import
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
|
9 |
-
#
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
-
# Create
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
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",
|
12 |
+
"--config_file", "./config/LS3DCG.json",
|
13 |
+
"--infer",
|
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 |
+
"--output_video", output_video # Ensure demo.py saves to this filename
|
19 |
+
]
|
20 |
+
|
21 |
+
# Run the command and capture the output
|
22 |
+
result = subprocess.run(command, capture_output=True, text=True)
|
23 |
+
|
24 |
+
# Check for errors
|
25 |
+
if result.returncode != 0:
|
26 |
+
return f"Error: {result.stderr}"
|
27 |
+
|
28 |
+
# Return the generated video file path
|
29 |
+
return output_video
|
30 |
|
31 |
+
# Create Gradio interface
|
32 |
+
interface = gr.Interface(
|
33 |
+
fn=run_inference,
|
34 |
+
inputs=gr.Audio(source="upload", type="filepath"),
|
35 |
+
outputs=gr.Video(type="file"),
|
36 |
+
title="Audio to Video Inference",
|
37 |
+
description="Upload an audio file to generate a video."
|
38 |
+
)
|
39 |
+
|
40 |
+
# Launch the app
|
41 |
+
if __name__ == "__main__":
|
42 |
+
interface.launch()
|