File size: 524 Bytes
0fec983
 
 
6a54c72
0fec983
 
 
 
 
 
 
 
 
 
 
a6dbf3b
0fec983
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from fastai.vision.all import *

learn = load_learner("export.pkl")

categories = ["Lala", "02"]


def classify_img(img):
    pred, idx, probs = learn.predict(img)
    return dict(zip(categories, map(float, probs)))


image = gr.inputs.Image(shape=(128, 128))
label = gr.outputs.Label()
examples = ["lala.jpg", "02.png"]

title = "02 or lala classifier"

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