insanecoder69 commited on
Commit
d26f817
·
verified ·
1 Parent(s): 7a989c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -11
app.py CHANGED
@@ -1,14 +1,42 @@
1
- import pyrender
2
- import numpy as np
3
- import trimesh
4
 
5
- # Create a simple mesh
6
- mesh = trimesh.Sphere(radius=1.0)
7
- mesh = pyrender.Mesh.from_trimesh(mesh)
8
 
9
- # Create a scene and add the mesh
10
- scene = pyrender.Scene()
11
- scene.add(mesh)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
- # Create a viewer
14
- pyrender.Viewer(scene, use_raymond_lights=True)
 
 
 
 
 
 
 
 
 
 
 
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()