import gradio as gr from fastai.vision.all import * import os categories = ("Goat 🐐", "No Goat 😬") model = load_learner('model.pkl') def classify_image(img): pred, idx, probs = model.predict(img) print("pred: ", pred) return dict(zip(categories, map(float, probs))) intf = gr.Interface( fn=classify_image, inputs=gr.Image(type="pil"), outputs=gr.Label(num_top_classes=2), examples=['images/cristiano.jpg', 'images/messi.jpg'] ) intf.launch(inline=False)