Spaces:
Runtime error
Runtime error
Download app.py from alonshini/bearClassifier: direct link, hf CLI and curl.
- Browser
- Download file 741 Bytes
-
https://huggingface.co/spaces/alonshini/bearClassifier/resolve/main/app.py
- Command line
-
hf download hf://spaces/alonshini/bearClassifier/app.py
-
curl -L -o app.py https://huggingface.co/spaces/alonshini/bearClassifier/resolve/main/app.py
741 Bytes
| __all__ = ['learn', 'categories', 'examples', 'interface', 'classify_image'] | |
| # %% 02_app.ipynb 1 | |
| from fastai.vision.all import * | |
| import gradio as gr | |
| print(gr.__version__) | |
| # %% 02_app.ipynb 2 | |
| learn = load_learner('model.pkl') | |
| # %% 02_app.ipynb 4 | |
| categories = ('black', 'grizzly', 'teddy') | |
| def classify_image(img): | |
| pred, pred_idx, probs = learn.predict(img) | |
| return dict(zip(categories, map(float, probs))) | |
| # %% 02_app.ipynb 5 | |
| # create a gradio interface | |
| # image = gr.inputs.Image(shape=(192,192)) | |
| # label = gr.outputs.Label() | |
| # examples = ['examples/black.jpg', 'examples/grizzly.jpg', 'examples/teddy.jpg'] | |
| interface = gr.Interface(fn=classify_image, inputs="image", outputs="label") | |
| interface.launch(inline=False, share=True) |