Spaces:
Sleeping
Sleeping
Download app.py from shuraimi/bear_classifier: direct link, hf CLI and curl.
- Browser
- Download file 708 Bytes
-
https://huggingface.co/spaces/shuraimi/bear_classifier/resolve/main/app.py
- Command line
-
hf download hf://spaces/shuraimi/bear_classifier/app.py
-
curl -L -o app.py https://huggingface.co/spaces/shuraimi/bear_classifier/resolve/main/app.py
708 Bytes
| __all__=['learn','classify_image','categories','examples','intf'] | |
| import gradio as gr | |
| from fastai.vision.all import * | |
| #load the learner | |
| learn=load_learner('bear_classifier_myver.pkl') | |
| # define categories | |
| categories=['Black bear','Grizzly bear','Teddy bear'] | |
| # define the function to classify images | |
| def classify_image(img): | |
| pred,idx,probs=learn.predict(img) | |
| return dict(zip(categories,map(float,probs))) | |
| # example images | |
| examples=['grizzly_bear1.jpg','grizzly_bear2.jpg','black+bear1.jpg','black_bear2.jpg','teddy1.jpg','teddy1.jpg'] | |
| # creating the interface | |
| intf=gr.Interface(fn=classify_image,inputs="image",outputs="label",examples=examples,title='Bear Classifier') | |
| intf.launch(inline=False) |