Spaces:
Runtime error
Runtime error
Download app.py from oshanmodi/which_bonsai: direct link, hf CLI and curl.
- Browser
- Download file 631 Bytes
-
https://huggingface.co/spaces/oshanmodi/which_bonsai/resolve/main/app.py
- Command line
-
hf download hf://spaces/oshanmodi/which_bonsai/app.py
-
curl -L -o app.py https://huggingface.co/spaces/oshanmodi/which_bonsai/resolve/main/app.py
631 Bytes
| import gradio as gr | |
| from fastai.vision.all import * | |
| import PIL.Image | |
| if not hasattr(PIL.Image, "Resampling"): # Pillow<9.0 | |
| PIL.Image.Resampling = PIL.Image | |
| learn = load_learner("_models/which_bonsai.pkl") | |
| categories = ["juniper", "ficus", "chinese elm", "japanese red maple"] | |
| def classify_image(img): | |
| pred, idx, probs = learn.predict(img) | |
| return dict(zip(categories, map(float, probs))) | |
| image = gr.inputs.Image(shape=(192, 192)) | |
| label = gr.outputs.Label() | |
| examples = ["1.jpeg", "2.jpeg", "3.jpeg"] | |
| intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
| intf.launch(inline=False) | |