Spaces:
Sleeping
Sleeping
File size: 701 Bytes
fc71058 a65ccd0 46ebe29 334e182 46ebe29 334e182 fc71058 334e182 fc71058 65b68de 5150d70 aae26ba fc71058 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
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("bears.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=["grizzly.jpg", "brown.jpg", "white.jpg", "black.jpg", "teddy.jpg"]
iface = gr.Interface(fn=classify_bear, inputs=image, outputs=label, examples=examples)
iface.launch(inline=False) |