Spaces:
Runtime error
Runtime error
File size: 646 Bytes
c69c3cf 0b94773 921e7f0 4b1db9b 921e7f0 c69c3cf 0b94773 c69c3cf 0b94773 c69c3cf 0b94773 |
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 |
import gradio as gr
from nbconvert import export
import numpy as np
from fastai.vision.all import *
import pathlib
import timm
plt = platform.system()
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
learner = load_learner("model.pkl")
categories = ('happy', 'upset')
def smileOrFrown(im):
pred,idx,probs = learner.predict(im)
actualPred = "happy"
if (pred == "human face upset"):
actualPred = "upset"
return actualPred + " " + str(dict(zip(categories, map(float, probs))))
demo = gr.Interface(
smileOrFrown,
gr.Image(source="webcam", streaming=True),
"text",
live=True
)
demo.launch() |