File size: 774 Bytes
9d245c2
 
 
 
 
 
 
 
 
 
 
 
 
27a8dea
9d245c2
 
8a93a69
9d245c2
 
 
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_attractiveness = load_learner('hotornot.pk1')
categories = ['hot', 'average', 'ugly']

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

intf = gr.Interface(fn=classify_attractiveness,
             inputs=gr.Image(shape=(192, 192)),
             outputs=gr.Label(),
             examples=['img01.jpg', 'img02.jpg', 'img03.jpg', 'img04.jpg', 'img05.jpg', 'img06.jpg', 'img07.jpeg', 'img08.jpg', 'img09.jpg', 'img10.jpg', 'img11.jpg', 'img12.jpg', 'img13.jpg', 'img14.jpg'])
intf.launch(inline=False)