File size: 494 Bytes
96032dc
9320334
 
96032dc
 
 
 
 
 
 
 
 
 
9320334
96032dc
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from fastai.vision.all import *
import gradio as gr

path = Path()
learn_inf = load_learner(path/'export.pkl')
def classify_image(img):
    pred,pred_idx,probs = learn_inf.predict(img)
    return f'Prediction: {pred}; Probability: float({probs[pred_idx]:.04f})'
    
image = gr.inputs.Image(shape=(224, 224))
label = gr.outputs.Label()
examples = ['1.jpg', '2.jpg', '3.jpg']
   

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