Spaces:
Sleeping
Sleeping
Download app.py from LLight/horse_donkey_classifier: direct link, hf CLI and curl.
- Browser
- Download file 855 Bytes
-
https://huggingface.co/spaces/LLight/horse_donkey_classifier/resolve/main/app.py
- Command line
-
hf download hf://spaces/LLight/horse_donkey_classifier/app.py
-
curl -L -o app.py https://huggingface.co/spaces/LLight/horse_donkey_classifier/resolve/main/app.py
855 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) | |
| preds,preds_idx,probs = learn.predict(img) | |
| return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
| title = 'Horse vs Donkey Classifier' | |
| description = 'A Horse versus Donkey classifier trained on using DuckDuckGo search engine. Created a demo as part of fastai course' | |
| examples = [Path('examples')/'donkey.jpg', Path('examples')/'horse.jpg', Path('examples')/'animated_horse.jpg', Path('examples')/'animated_donkey.jpg', Path('examples')/'hybrid.jpg'] | |
| iface = gr.Interface(fn=predict, inputs=gr.inputs.Image(type='pil', shape=(224, 224)), title=title, description=description, outputs=gr.outputs.Label(num_top_classes=2), examples=examples, enable_queue=True) | |
| iface.launch() |