import gradio as gr
from fastai.vision.all import load_learner


learn = load_learner("export.pkl")
categories = ("black", "grizzly", "teddy")


def classify_image(img):
    _, _, probs = learn.predict(img)
    return dict(zip(categories, map(float, probs)))


image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
examples = ["black.jpg", "grizzly.jpg", "teddy.jpg"]


iface = gr.Interface(
    fn=classify_image, inputs="image", outputs="text", examples=examples
)

iface.launch()