Spaces:
Runtime error
Runtime error
Download app.py from ChrisOlande/Butterfly_Image_Classifier: direct link, hf CLI and curl.
- Browser
- Download file 794 Bytes
-
https://huggingface.co/spaces/ChrisOlande/Butterfly_Image_Classifier/resolve/main/app.py
- Command line
-
hf download hf://spaces/ChrisOlande/Butterfly_Image_Classifier/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ChrisOlande/Butterfly_Image_Classifier/resolve/main/app.py
794 Bytes
| from fastai.vision.all import * | |
| import gradio as gr | |
| learn = load_learner('export.pkl') | |
| labels = learn.dls.vocab | |
| def predict(img): | |
| img = PILImage.create(img) | |
| pred,pred_idx,probs = learn.predict(img) | |
| return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
| examples = ['adonis.jpg', | |
| 'atlas moth.jpg', | |
| 'american snoot.jpg'] | |
| title = "ButterFly Image Classifier🦋" | |
| description = "A ResNet18 feature extractor computer vision model to classify images of butterfly in 100 classes!" | |
| article = "[Chris Olande.](https://github.com/Chrisolande)" | |
| image = gr.Image() | |
| label = gr.Label(num_top_classes = 3) | |
| gr.Interface(fn=predict, inputs=image, outputs=label, examples = examples, title = title, description = description, article = article).launch(share=True) | |