Spaces:
Sleeping
Sleeping
Download app.py from ntrinh/dogs_classifier: direct link, hf CLI and curl.
- Browser
- Download file 808 Bytes
-
https://huggingface.co/spaces/ntrinh/dogs_classifier/resolve/main/app.py
- Command line
-
hf download hf://spaces/ntrinh/dogs_classifier/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ntrinh/dogs_classifier/resolve/main/app.py
808 Bytes
| import gradio as gr | |
| from fastai.vision.all import * | |
| learn = load_learner('cuttest_dogs_model.pkl') | |
| labels = learn.dls.vocab # list of model classes | |
| 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))} | |
| gr.Interface( | |
| fn=predict, | |
| inputs=gr.inputs.Image(shape=(512, 512)), | |
| outputs=gr.outputs.Label(num_top_classes=5), | |
| title="The Cuttest Dogs Classifier 🐶🐕🦮🐕🦺", | |
| description="Classifier trainded on images of huskies, retrievers, pomeranians, corgis and samoyeds. Created as a demo for Deep Learning app using HuggingFace Spaces & Gradio.", | |
| examples=['husky.jpg', 'retriever.jpg', 'corgi.jpg', 'pomeranian.jpg', 'samoyed.jpg'], | |
| enable_queue=True).launch() | |