Spaces:
Build error
Build error
Download app.py from gzcui163/First_task: direct link, hf CLI and curl.
- Browser
- Download file 586 Bytes
-
https://huggingface.co/spaces/gzcui163/First_task/resolve/main/app.py
- Command line
-
hf download hf://spaces/gzcui163/First_task/app.py
-
curl -L -o app.py https://huggingface.co/spaces/gzcui163/First_task/resolve/main/app.py
586 Bytes
| from fastai.vision.all import * | |
| import gradio as gr | |
| learn = load_learner('model.pkl') | |
| labels = learn.dls.vocab | |
| def predict(img): | |
| img = PILImage.create(img) | |
| pred,pred_idx,probs = learn.predict(img) | |
| return dict(zip(labels, map(float, probs))) | |
| title = "Lion Tiger Classifier" | |
| examples = ['lion.jpg', 'tiger.jpg', 'tigon.jpg', 'liger.jpg'] | |
| demo = gr.Interface(fn=predict, | |
| inputs=gr.Image('lion.jpg'), | |
| outputs=gr.Label(), | |
| title=title, | |
| examples=examples) | |
| demo.launch(inline=False, show_error=True) | |