from fastai.vision.all import * import gradio as gr # necessary for load_learner not to complain about missing functions def is_cat(x): return x[0].isupper() learn = load_learner('model.pkl') categories = ('Dog ', 'Cat') def classify_image(img): pred,idx,probs = learn.predict(img) return dict(zip(categories, map(float,probs))) inp_img = gr.inputs.Image(shape=(200,200)) out_label = gr.outputs.Label() iface = gr.Interface(fn=classify_image, inputs=inp_img, outputs=out_label, title="Pet classifier") iface.launch(inline=False)