Spaces:
Runtime error
Runtime error
Download app.py from nishantkdtech/dog: direct link, hf CLI and curl.
- Browser
- Download file 767 Bytes
-
https://huggingface.co/spaces/nishantkdtech/dog/resolve/main/app.py
- Command line
-
hf download hf://spaces/nishantkdtech/dog/app.py
-
curl -L -o app.py https://huggingface.co/spaces/nishantkdtech/dog/resolve/main/app.py
767 Bytes
| __all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf'] | |
| from fastai.vision.all import * | |
| import gradio as gr | |
| learn = load_learner('export.pkl') | |
| categories = ('Cat', 'Dog', 'Hampster') | |
| def classify_image(img): | |
| pred, idx, probs = learn.predict(img) | |
| return dict(zip(categories, map(float, probs))) | |
| image=gr.Image(height = 192, width = 192) | |
| label = gr.Label() | |
| examples = ['92e4069f-7e8d-43ab-bf44-1a3426c236f8.jpg','34f0c26d-3f52-44f7-bec8-6f17ea662f1b.jpg', | |
| '1466b365-2800-4558-8d3b-458679828bcc.jpg','2f0f017c-c4dc-452a-b246-d1b57569c36b.jpg', | |
| 'f7ac1a93-7028-4f94-b84b-363dd978b663.jpg'] | |
| intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
| intf.launch(inline=False) | |