Spaces:
Runtime error
Runtime error
Download app.py from onato/pest-classifier: direct link, hf CLI and curl.
- Browser
- Download file 788 Bytes
-
https://huggingface.co/spaces/onato/pest-classifier/resolve/main/app.py
- Command line
-
hf download hf://spaces/onato/pest-classifier/app.py
-
curl -L -o app.py https://huggingface.co/spaces/onato/pest-classifier/resolve/main/app.py
788 Bytes
| import gradio as gr | |
| from fastai.vision.all import * | |
| import skimage | |
| learn = load_learner('model.pkl') | |
| categories = 'possum', 'rat' | |
| def classify_image(img): | |
| pred,idx,probs = learn.predict(img) | |
| return dict(zip(categories, map(float,probs))) | |
| title = "Pest Classifier" | |
| description = "This model classifies images of pests into 2 categories: 'Possum' or 'Rat'" | |
| article="This is just me following the lesson 2 of the fastai course. I used the siamese network to classify the pests." | |
| examples = ['possum.jpg', 'rat.jpg'] | |
| interpretation='default' | |
| enable_queue=True | |
| interface = gr.Interface( | |
| fn=classify_image, | |
| inputs=gr.Image(), | |
| outputs=gr.Label(), | |
| title=title, | |
| description=description, | |
| article=article, | |
| examples=examples | |
| ) | |
| interface.launch(share=True) | |