File size: 532 Bytes
e6d5d30
 
 
1cf582b
e6d5d30
 
 
 
 
 
 
 
ab0fc9e
44901fc
e6d5d30
 
 
 
06e3efb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr
from fastai.vision.all import *

categories = ('Leonardo_da_Vinci', 'Vincent_van_Gogh')
learn = load_learner('painter.pkl')


def classify_painter(img):
    painter, _, probs = learn.predict(img)
    return dict(zip(categories, map(float, probs)))


image = gr.Image(height = 192, width = 192)
label = gr.Label()
examples = ['davinci.jpeg', 'vangogh.jpeg', 'picasso.jpeg']

iface = gr.Interface(fn=classify_painter, inputs=image,
                     outputs=label, examples=examples)
iface.launch(inline=False)