File size: 949 Bytes
f6aa5b4
 
 
 
 
 
 
20502e3
f6aa5b4
 
127101e
f6aa5b4
 
 
 
 
7e3d766
 
a3ce231
f6aa5b4
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
__all__ = ['learner_faces', 'categories', 'classify_faces', 'image', 'label', 'examples', 'intf']

from fastai.vision.all import *
import gradio as gr


learner_faces = load_learner('faces_resenet50_78.pk1')
categories = ['sad', 'happy', 'angry']

def classify_faces(img):
  prediction, index, probability = learner_faces.predict(img)
  return dict(zip(categories, map(float, probability)))

intf = gr.Interface(fn=classify_faces,
             inputs=gr.Image(shape=(192, 192)),
             outputs=gr.Label(),
             title='Happy, Sad, or Angry?',
             description="Put in a picture and see what the AI thinks the expression on the face is. Happy is easy, but sad and angry are eerily similar!",
             examples=['face01.jpg', 'face13.jpg', 'face02.jpg', 'face07.jpg', 'face10.jpeg', 'face11.jpg', 'face03.jpg', 'face04.jpg', 'face12.jpg', 'face05.jpg', 'face09.jpeg', 'face06.jpg', 'face08.jpeg'])
intf.launch(inline=False)