import gradio as gr from fastai.vision.all import * f = Path() / 'bamboo_or_butterfly.pkl' learn_inf = load_learner(f) def predict(img): pred, pred_idx, probs = learn_inf.predict(img) return f'Prediction: {pred}; Probability:{probs[pred_idx]:.04f}' image = gr.inputs.Image(shape=(192, 192)) label = gr.outputs.Label() iface = gr.Interface(fn=predict, inputs=image, outputs=label) iface.launch(inline=False)