Download app.py from Mgcini/image: direct link, hf CLI and curl.
- Browser
- Download file 726 Bytes
-
https://huggingface.co/spaces/Mgcini/image/resolve/main/app.py
- Command line
-
hf download hf://spaces/Mgcini/image/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Mgcini/image/resolve/main/app.py
726 Bytes
| # AUTOGENERATED! DO NOT EDIT! File to edit: deploy.ipynb. | |
| # %% auto 0 | |
| __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'is_cat', 'classify_image'] | |
| # %% deploy.ipynb 2 | |
| from fastai.vision.all import* | |
| import gradio as gr | |
| def is_cat(x): return x[0].isupper() | |
| # %% deploy.ipynb 5 | |
| learn = load_learner('model.pkl') | |
| # %% deploy.ipynb 7 | |
| categories = ("Dog", "Cat") | |
| def classify_image(img): | |
| pred,idx,probs = learn.predict(img) | |
| return dict(zip(categories, map(float,probs))) | |
| # %% deploy.ipynb 9 | |
| image = gr.Image(type='pil') | |
| label = gr.Label() | |
| examples=['dogt1.jpg','Siberian-Cat.jpg'] | |
| intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
| intf.launch(inline=True) | |