CoolFace
Apppublic

pengsida/NeuralBody

sourceHugging Faceupdated 2y agoView on Hugging Face
1likes
app.py45 linesDownload Raw Back to root
1import os2import gradio as gr3import subprocess4from lib.config import args5 6def process_video(video_path, task):7    """8    Function to process the input video and run the NeuralBody pipeline.9    """10    # Save uploaded video locally11    input_video = "input_video.mp4"12    os.system(f"cp {video_path} {input_video}")13 14    # Map tasks to functions in run.py15    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.py26    args.type = task_map[task]  # Set the correct function call in run.py27    subprocess.run(["python", "run.py"], check=True)28 29    return f"Task '{task}' completed! Check the output directory."30 31# Gradio UI32iface = 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 43if __name__ == "__main__":44    iface.launch()45