Spaces:
No application file
No application file
Download foo.py from diffindiff/experimentation: direct link, hf CLI and curl.
- Browser
- Download file 643 Bytes
-
https://huggingface.co/spaces/diffindiff/experimentation/resolve/main/foo.py
- Command line
-
hf download hf://spaces/diffindiff/experimentation/foo.py
-
curl -L -o foo.py https://huggingface.co/spaces/diffindiff/experimentation/resolve/main/foo.py
643 Bytes
| __all__ = ['categories', 'image', 'label', 'examples', 'intf', 'is_cat', 'classify_image'] | |
| from fastai.vision.all import * | |
| import gradio as gr | |
| def is_cat(x): | |
| return x[0].isupper() | |
| categories = ('Dog', 'Cat') | |
| learn = load_learner('model.pkl') | |
| def classify_image(img): | |
| pred, idx, probs = learn.predict(img) | |
| return dict(zip(categories, map(float, probs))) | |
| image = gr.components.Image(height = 192, width = 192) | |
| label = gr.components.Label() | |
| examples = ['example-dog.jpg', 'example-cat.jpg'] | |
| intf = gr.Interface(fn = classify_image, inputs = image, outputs = label, examples = examples) | |
| intf.launch(inline = False, share=True) | |