File size: 419 Bytes
86e2ff2
84f9b06
86e2ff2
7ec7dca
 
 
3a9752a
71a2079
3a9752a
7ec7dca
992fc6d
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import gradio as gr
from fastai.vision.all import *

f = Path() / 'bamboo_or_butterfly.pkl'
learn_inf = load_learner(f)

def predict(img):
    pred, pred_idx, probs = learn_inf.predict(img)
    return f'Prediction: {pred}; Probability:{probs[pred_idx]:.04f}'

image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()

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