Download app.py from Mel-Mac/DogCat: direct link, hf CLI and curl.
- Browser
- Download file 811 Bytes
-
https://huggingface.co/spaces/Mel-Mac/DogCat/resolve/main/app.py
- Command line
-
hf download hf://spaces/Mel-Mac/DogCat/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Mel-Mac/DogCat/resolve/main/app.py
811 Bytes
| # AUTOGENERATED! DO NOT EDIT! File to edit: ../modelexport.ipynb. | |
| # %% auto 0 | |
| __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'cat_breed', 'classify_image'] | |
| # %% ../modelexport.ipynb 3 | |
| from fastai.vision.all import * | |
| import gradio as gr | |
| def cat_breed(x): return x[0].isupper() | |
| # %% ../modelexport.ipynb 18 | |
| learn = load_learner('model.pkl') | |
| categories = 'bengal','domestic_shorthair', 'maine_coon', 'ragdoll', 'siamese' | |
| def classify_image(img): | |
| pred,idx,probs = learn.predict(img) | |
| return dict(zip(categories, map(float, probs))) | |
| image = gr.Image() | |
| label = gr.Label() | |
| examples = ['bengal.jpg', 'shorthair.jpg','maine_coon.jpg','ragdoll.jpg','siamese.jpg'] | |
| intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
| intf.launch(inline=False) | |