File size: 453 Bytes
590447b
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from fastai.vision.all import *
import gradio as gr


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


learn_inf = load_learner('model/cat_dog_classifer.pkl')
labels = learn_inf.dls.vocab
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(224, 224)),
             outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)