File size: 891 Bytes
f0f1aaa
 
 
c04ef19
 
f0f1aaa
 
88bde5d
4bf1a31
f0f1aaa
 
 
 
 
 
4bf1a31
1b1d8c1
f0f1aaa
 
 
 
 
c04ef19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from face_emotion_pipeline import process_video, process_image

def process_file(file, is_video , skip = 1  , add_audio = True):
    # print("==========>", is_video)
    input_path = file.name
    output_path = "output." + ("mp4" if is_video else "png")
    if is_video == True:
        process_video(input_path, output_path , skip = round(skip)  , add_audio = add_audio)
    else:
        process_image(input_path, output_path)
    return output_path

iface = gr.Interface(
    fn=process_file,
    inputs=[gr.File(label="Upload File"), gr.Checkbox(label="Is Video?") , gr.Slider(1, 20, 1, value=1, label="Frame Skip"), gr.Checkbox(label="Add Audio?")],
    outputs=gr.File(label="Processed File"),
    title="Face Emotion Detection",
    description="Upload an image or video to detect and annotate emotions."
)

if __name__ == "__main__":
    iface.launch(share=True)