File size: 801 Bytes
efc4084
 
 
0b75987
32862f1
0b75987
32862f1
 
aebb690
32862f1
 
 
 
 
864f69a
 
 
 
499ed76
 
 
 
864f69a
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# %% auto 0
__all__ = ['dls', 'labels', 'interface', 'predict']

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

learn = load_learner('export.pkl')
labels = learn.dls.vocab

def classify_image(img):
    img = PILImage.create(img)
    pred, idx, probs = learn.predict(img)
    return {labels[i]: float(probs[i]) for i in range(len(labels))}

interface = gr.Interface(
    fn=classify_image, 
    inputs=gr.Image(height=512, width=512), 
    outputs=gr.Label(num_top_classes=3),
    title="Mexican Muralist Classifier",
    description="Upload a photo of a mural created by Rivera, Orozco or Siqueiros.",
    article="This classifier can distinguish between the murals created by these three great artists.",
    examples=['siqueiros.jpg', 'rivera.jpg', 'orozco.jpg']
)
interface.launch(share=True)