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)