CoolFace
Apppublic

Jayare/Facial

sourceHugging Faceupdated 4y agoView on Hugging Face
0likes
To create the script (1).py34 linesDownload Raw Back to root
1#!/usr/bin/env python2# coding: utf-83 4# In[2]:5 6 7from fastai.vision.all import *8import gradio as gr9 10import pathlib11temp = pathlib.PosixPath12pathlib.PosixPath = pathlib.WindowsPath13 14learner = load_learner("facial_expression_class.pkl")15categories = ('happy','sad','scared', 'angry', 'surprised')16 17def classify_emotion(img):18    pred,idx,probs = learner.predict(img)19    return dict(zip(categories,map(float,probs)))20 21image= gr.inputs.Image(shape =(192,192))22label = gr.outputs.Label()23examples= ["download (1).jpg"]24 25intf = gr.Interface(fn=classify_emotion, inputs=image, outputs=label,examples=examples)26intf.launch(inline=False)27 28 29# In[ ]:30 31 32 33 34