File size: 703 Bytes
f6aa5b4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c1dbed6
f6aa5b4
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
__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 = ['happy', 'sad', 'angry']

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

intf = gr.Interface(fn=classify_faces,
             inputs=gr.Image(shape=(192, 192)),
             outputs=gr.Label(),
             examples=['face01', 'face13', 'face02', 'face07', 'face10', 'face11', 'face03', 'face04', 'face12', 'face05', 'face09', 'face06', 'face08', 'face09'])
intf.launch(inline=False)