Download app.py from leftbyte/beartype: direct link, hf CLI and curl.
- Browser
- Download file 683 Bytes
-
https://huggingface.co/spaces/leftbyte/beartype/resolve/main/app.py
- Command line
-
hf download hf://spaces/leftbyte/beartype/app.py
-
curl -L -o app.py https://huggingface.co/spaces/leftbyte/beartype/resolve/main/app.py
683 Bytes
| from fastai.vision.all import * | |
| import gradio as gr | |
| categories = ('black', 'grizzly', 'teddy') | |
| def classify_image(img): | |
| pred, idx, probs = learn.predict(img) | |
| return dict(zip(categories, map(float, probs))) | |
| def greet(name): | |
| return "Hello " + name + "!!" | |
| # gr.Interface(fn=greet, inputs="text", outputs="text").launch | |
| learn = load_learner('model/bears.pkl') | |
| image = gr.inputs.Image(shape=(192, 192)) | |
| label = gr.outputs.Label() | |
| examples = ['images/black.jpg', 'images/grizzly.jpg', 'images/teddy.jpg'] | |
| intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
| intf.launch(inline=False) | |
| # m = learn.model | |
| # ps = list(m.parameters()) | |
| # ps[1] | |