Download app.py from anewsha/myfirst: direct link, hf CLI and curl.
- Browser
- Download file 718 Bytes
-
https://huggingface.co/spaces/anewsha/myfirst/resolve/main/app.py
- Command line
-
hf download hf://spaces/anewsha/myfirst/app.py
-
curl -L -o app.py https://huggingface.co/spaces/anewsha/myfirst/resolve/main/app.py
718 Bytes
| # AUTOGENERATED! DO NOT EDIT! File to edit: ../pickerfile.ipynb. | |
| # %% auto 0 | |
| __all__ = ['learn', 'categories', 'image', 'label', 'Examples', 'classify_image'] | |
| # %% ../pickerfile.ipynb 3 | |
| from fastai.vision.all import * | |
| import gradio as gr | |
| # %% ../pickerfile.ipynb 4 | |
| learn = load_learner("model.pkl") | |
| # %% ../pickerfile.ipynb 7 | |
| categories = {'teddy bear','black bear','grizzly bear'} | |
| def classify_image(img): | |
| pred,idx,probs = learn.predict(img) | |
| return dict(zip(categories, map(float,probs))) | |
| # %% ../pickerfile.ipynb 9 | |
| image = gr.Image() | |
| label = gr.Label() | |
| Examples = ['teddybear.jpg','blackbear.jpg','grizzlybear.jpg'] | |
| gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=Examples).launch() | |