Spaces:
Runtime error
Runtime error
| import sys | |
| import pathlib | |
| if sys.platform == "win32": | |
| temp = pathlib.PosixPath | |
| pathlib.PosixPath = pathlib.WindowsPath | |
| from fastai.vision.all import * | |
| import gradio as gr | |
| learn = load_learner(Path("model.pkl")) | |
| categories = {'Pizza', 'Pasta'} | |
| def classify_image(img): | |
| pred, idx, probs = learn.predict(img) | |
| return dict(zip(categories, map(float, probs))) | |
| image = gr.Image(shape=(192, 192)) | |
| label = gr.Label() | |
| examples = ['pizza.jpg', 'pasta.jpg', 'dunno.jpg'] | |
| app = gr.Interface(fn=classify_image, | |
| inputs=image, | |
| outputs=label, | |
| examples=examples) | |
| app.launch() | |