import gradio as gr from fastai.vision.all import * learn = load_learner("cat.pkl") classes = learn.vocab examples = learn.examples def classify_image(img): probs = learn.predict(img)[2] return dict(zip(classes, map(float, probs))) image = gr.Image() label = gr.Label(num_top_classes=5) intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) intf.launch()