File size: 1,413 Bytes
a935d95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64d8365
 
 
a935d95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5195ba0
a935d95
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import gradio as gr
import os 
import subprocess
import tempfile
from glob import glob

def run_inference(image_input, audio_input):

    # Create a temporary folder for downloaded and processed images
    temp_dir = tempfile.mkdtemp()

    try:
        # Run the inference command
        subprocess.run(
            [
                "python", "inference.py",
                "--config", "configs/inference.yaml",
                "--input_image", image_input,
                "--input_audio", audio_input,
                "--output_dir", temp_dir,
            ],
            check=True
        )

        # Collect the output images
        output_video = glob(os.path.join(temp_dir, "*.mp4"))
        return output_video[0]
    except subprocess.CalledProcessError as e:
        raise gr.Error(f"Error during inference: {str(e)}")

with gr.Blocks() as demo:
    with gr.Column():
        gr.Markdown("# MEMO")
        with gr.Row():
            with gr.Column():
                image_input = gr.Image(label="Image Input", type="filepath")
                audio_input = gr.Audio(label="Audio Input", type="filepath")
                submit_btn = gr.Button("Submit")
            with gr.Column():
                output_result = gr.Video(label="Result")

    submit_btn.click(
        fn =run_inference,
        inputs =[image_input, audio_input],
        outputs = [output_result]
    )

demo.queue().launch()