File size: 898 Bytes
0dfe33d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import glob
import os

from src.core import load_model, predict_traits

TRAIT_NAMES = [
    "Extraversion",
    "Agreeableness",
    "Conscientiousness",
    "Neurotisicm",
    "Openness",
]


def get_traits(video):
    model = load_model()
    # if webcam_video:
    #     trait_values = predict_traits(webcam_video, model)
    # else:
    trait_values = predict_traits(video, model)
    return {k: float(v) for k, v in zip(TRAIT_NAMES, trait_values)}


demo = gr.Interface(
    get_traits,
    inputs=gr.Video(label="Video", include_audio=True),
    outputs=gr.Label(num_top_classes=5, label="Results"),
    title="Personality Traits Prediction [Prototype]",
    description="Predicts the 5 psychological traits using an introduction video",
    thumbnail="https://cdn-icons-png.flaticon.com/512/3392/3392044.png",
    examples="egs",
    cache_examples=True,
)
demo.launch()