Spaces:
Sleeping
Sleeping
Download app.py from jeorjesami/cat_dog_classifier: direct link, hf CLI and curl.
- Browser
- Download file 564 Bytes
-
https://huggingface.co/spaces/jeorjesami/cat_dog_classifier/resolve/main/app.py
- Command line
-
hf download hf://spaces/jeorjesami/cat_dog_classifier/app.py
-
curl -L -o app.py https://huggingface.co/spaces/jeorjesami/cat_dog_classifier/resolve/main/app.py
564 Bytes
| import gradio as gr | |
| from fastai.vision.all import * | |
| def is_cat(x): return x[0].isupper() | |
| learner = load_learner("model.pkl") | |
| categories = ("Dog", "Cat") | |
| def classify_image(img): | |
| if img is None: | |
| return {} | |
| img = PILImage.create(img) | |
| pred, pred_idx, probs = learner.predict(img) | |
| return dict(zip(categories, map(float, probs))) | |
| demo = gr.Interface( | |
| fn=classify_image, | |
| inputs=gr.Image(type="pil"), | |
| outputs=gr.Label(), | |
| examples=["cat1.jpeg", "dog1.jpeg", "cat2.jpeg", "dog2.jpg"], | |
| cache_examples=False, | |
| ) | |
| demo.launch() | |