Spaces:
Runtime error
Runtime error
Download app.py from studies/first-model: direct link, hf CLI and curl.
- Browser
- Download file 545 Bytes
-
https://huggingface.co/spaces/studies/first-model/resolve/main/app.py
- Command line
-
hf download hf://spaces/studies/first-model/app.py
-
curl -L -o app.py https://huggingface.co/spaces/studies/first-model/resolve/main/app.py
545 Bytes
| import gradio as gr | |
| from fastai.vision.all import * | |
| learn = load_learner('model.pkl') | |
| categories = ('Golf', 'Soccer') | |
| def classify_image(img): | |
| pred,idx,probs = learn.predict(img) | |
| return dict(zip(categories, map(float, probs))) | |
| image = gr.Image() # No need for the shape argument | |
| label = gr.Label() | |
| iface = gr.Interface(fn=classify_image, inputs=image, outputs=label) | |
| iface.launch(inline=False) | |
| # def greet(name): | |
| # return "Hello " + name + "!!" | |
| # iface = gr.Interface(fn=greet, inputs="text", outputs="text") | |
| # iface.launch() |