from fastai import * from fastai.vision.all import * import gradio as gr import pathlib # def is_cat(x): return x[0].isupper() # Ensure that the correct Path object is used here based on the OS # pathlib.PosixPath = pathlib.WindowsPath # path = Path() model_path = str(Path('export.pkl')) learn = load_learner(model_path) # learn = load_learner(path/'export.pkl') categories = ('black', 'grizzly', 'teddy') def classify_image(img): pred, idx, probs = learn.predict(img) return dict(zip(categories, map(float, probs))) image = gr.components.Image(type="pil", height=192, width=192) label = gr.Label() examples = ['bear.jpg', 'cat.jpg', 'dog.jpg'] intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) intf.launch(inline=False)