Spaces:
Runtime error
Runtime error
Download app.py from Neall/microbe-classifier2: direct link, hf CLI and curl.
- Browser
- Download file 562 Bytes
-
https://huggingface.co/spaces/Neall/microbe-classifier2/resolve/main/app.py
- Command line
-
hf download hf://spaces/Neall/microbe-classifier2/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Neall/microbe-classifier2/resolve/main/app.py
562 Bytes
| import gradio as gr | |
| from fastai.vision.all import * | |
| examples = ['samples/paramecium.jpg', | |
| 'samples/euglena.jpg', 'samples/hydra.jpg', 'samples/yeast.jpg', 'samples/amoeba.png'] | |
| learn = load_learner('microbe_model.pkl') | |
| def classify_image(img): | |
| category_name, _, probs = learn.predict(img) | |
| categories = learn.dls.vocab | |
| return {category: f"{prob:.4f}" for category, prob in zip(categories, probs.tolist())} | |
| iface = gr.Interface(fn=classify_image, inputs="image", | |
| outputs="label", examples=examples) | |
| iface.launch() | |