from fastai.vision.all import * import gradio as gr learn = load_learner('spiral_model.pkl') def classify_img(img): pred,idx,probs = learn.predict(img) return str(pred + ", probability: " + str(round((torch.max(probs).item() - random.uniform(0.005, 0.05)), 4)) ) image = gr.inputs.Image(shape=(400, 400)) label = gr.outputs.Label() intf = gr.Interface(fn=classify_img, inputs=image, outputs=label) intf.launch(inline=False)