Spaces:
Sleeping
Sleeping
| from fastai.vision.all import * | |
| from huggingface_hub import push_to_hub_fastai, from_pretrained_fastai | |
| import gradio as gr | |
| #learner = from_pretrained_fastai("kolkhi/bears") | |
| learner = load_learner("model.pkl") | |
| categories = learner.dls.vocab | |
| def classify_bear(img): | |
| img_new = PILImage.create(img) | |
| img_new.resize((128,128)) | |
| pred,idx,probs=learner.predict(img_new) | |
| return dict(zip(categories, map(float,probs))) | |
| image = gr.components.Image(width=192,height=192) | |
| label = gr.components.Label() | |
| examples=["deer.jpg", "wolf.jpg", "car.jpg", "ship.jpg"] | |
| iface = gr.Interface(fn=classify_bear, inputs=image, outputs=label, examples=examples) | |
| iface.launch(inline=False, share=True) |