File size: 699 Bytes
16cf1ad
af3e0f6
 
2a29d13
 
e34b118
af3e0f6
b34bbc3
25e8fcd
 
af3e0f6
16cf1ad
39d5445
 
 
 
 
e10e9b7
25e8fcd
16cf1ad
39d5445
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from fastai.vision.all import *

from PIL import Image

learn_inf = load_learner("export.pkl")

def predict(value) -> str:
   img = Image.fromarray(value).convert('LA')
   pred,pred_idx,probs = learn_inf.predict(img)
   return f"{pred} at {probs[pred_idx]}"

with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column():
            input_img = gr.Image(label="Input", sources="webcam")
        with gr.Column():
            output_lbl = gr.Label(value="Output", label="Expression Prediction")
        input_img.stream(fn=predict, inputs=input_img, outputs=output_lbl, time_limit=15, stream_every=0.1, concurrency_limit=30)

if __name__ == "__main__":

    demo.launch()