from fastai.vision.all import * import gradio as gr learn = load_learner("model.pkl") categories = ("Cat", "Dog") def classify_image(image): pred, i, prob = learn.predict(image) return dict(zip(categories, map(float, prob))) image = gr.inputs.Image(shape=(192, 192)) label = gr.outputs.Label() examples = ["images/cat.jpg", "images/dog.jpg", "images/dunno.jpg"] interface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) interface.launch(inline=False)