Files changed (1) hide show
  1. app.py +44 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ import subprocess
4
+ from lib.config import args
5
+
6
+ def process_video(video_path, task):
7
+ """
8
+ Function to process the input video and run the NeuralBody pipeline.
9
+ """
10
+ # Save uploaded video locally
11
+ input_video = "input_video.mp4"
12
+ os.system(f"cp {video_path} {input_video}")
13
+
14
+ # Map tasks to functions in run.py
15
+ task_map = {
16
+ "Dataset Processing": "dataset",
17
+ "Network Inference": "network",
18
+ "Evaluation": "evaluate",
19
+ "Visualization": "visualize",
20
+ }
21
+
22
+ if task not in task_map:
23
+ return "Invalid task selected!"
24
+
25
+ # Run corresponding function in run.py
26
+ args.type = task_map[task] # Set the correct function call in run.py
27
+ subprocess.run(["python", "run.py"], check=True)
28
+
29
+ return f"Task '{task}' completed! Check the output directory."
30
+
31
+ # Gradio UI
32
+ iface = gr.Interface(
33
+ fn=process_video,
34
+ inputs=[
35
+ gr.Video(label="Upload Video"),
36
+ gr.Radio(["Dataset Processing", "Network Inference", "Evaluation", "Visualization"], label="Select Task"),
37
+ ],
38
+ outputs="text",
39
+ title="NeuralBody: Video-Based 3D Reconstruction",
40
+ description="Upload a video and choose a task to perform using the NeuralBody pipeline."
41
+ )
42
+
43
+ if __name__ == "__main__":
44
+ iface.launch()