Spaces:
Runtime error
Runtime error
| import subprocess | |
| import sys | |
| subprocess.check_call([sys.executable, "-m", "pip", "install", "fastai"]) | |
| from fastai.vision.all import * | |
| import gradio as gr | |
| __all__ = ['is_cat', 'label', 'image', 'intf', 'examples', 'categories', 'learn'] | |
| def is_cat(x): return x[0].isupper() | |
| learn = load_learner('my_model.pkl') | |
| categories = ('Healthy Fungi', 'Poisonous Fungi') | |
| def classify_image(img): | |
| pred, idx, probs = learn.predict(img) | |
| return dict(zip(categories, map(float, probs))) | |
| from gradio.components import Image, Label | |
| label = Label() | |
| image = Image() #shape = (192, 192) | |
| examples=[ | |
| "healthy_fungi.jpg", "Death-cap-mushroom.jpg"] | |
| intf = gr.Interface(fn = classify_image, inputs = image, outputs = label, examples = examples) | |
| # Launch the web interface with the image and label components | |
| intf.launch(inline = False) |