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) | |