from fastai.vision.all import * import gradio learn = load_learner('export.pkl') labels = learn.dls.vocab def predict(img): img = PILImage.create(img) pred,pred_idx,probs = learn.predict(img) return {labels[i]: float(probs[i]) for i in range(len(labels))} image = gradio.Image(height=512, width=512) label = gradio.Label(num_top_classes=3) gradio.Interface(fn=predict, inputs=image, outputs=label).launch(share=True)