File size: 808 Bytes
4dfc07d
 
 
 
 
 
 
 
 
 
 
 
 
536f434
 
 
0714d9a
536f434
 
4dfc07d
 
 
 
 
ecd5491
 
4dfc07d
 
 
ecd5491
4dfc07d
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from fastai.vision.all import *
import gradio as gr

learn = load_learner('export.pkl')

labels = learn.dls.vocab
def predict(img_fnm):
    img = PILImage.create(img_fnm)
    pred, pred_idx, probs = learn.predict(img)
    return {label: float(prob) for label, prob in zip(labels, probs)}

title = "Moody-nana Classifier"
description = "Classifies an image as either happy, angry, or banana."
examples = [
    "examples/angry-banana.jpg",
    "examples/angry.jpg",
    "examples/happy.jpg",
    "examples/banana.jpg"
]
interpretation = "default"
enable_queue = True

intf = gr.Interface(
    fn=predict,
    inputs=gr.components.Image(shape=(512, 512)),
    outputs=gr.components.Label(),
    title=title,
    description=description,
    examples=examples,
    interpretation=interpretation
)

intf.launch()