import gradio as gr from fastai.vision.all import * from pathlib import Path import pathlib hugging_face = True if not hugging_face: temp = pathlib.PosixPath pathlib.PosixPath = pathlib.WindowsPath learn = load_learner(Path("./model.pkl")) def predict_image(image): pred, pred_idx, probs = learn.predict(image) return pred, probs[pred_idx].item() app = gr.Interface(fn=predict_image, inputs=gr.Image(type="pil"), outputs=[gr.Label(), gr.Number()], live=True ) app.launch()