Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from fastai.vision.all import * | |
| import skimage | |
| from huggingface_hub import from_pretrained_fastai | |
| def label_func(f): return f.name[:2] | |
| learn = from_pretrained_fastai("smaciu/bee-wings-classifier") | |
| labels = learn.dls.vocab | |
| def predict(img): | |
| #img = PILImage.create(img) | |
| pred,pred_idx,probs = learn.predict(img) | |
| return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
| title="Honey Bee Wing Classifier" | |
| description = "A bee wings classifier trained with fastai" | |
| examples = ['ES-0003-2092-0.dw.png','HU-0001-2019-000007-R.dw.png','PL-0002-000187-R.dw.png'] | |
| enable_queue=True | |
| gr.Interface(fn=predict, | |
| inputs=gr.inputs.Image(type='pil'), | |
| outputs=gr.outputs.Label(num_top_classes=3), | |
| title=title, | |
| description=description, | |
| examples=examples, | |
| enable_queue=enable_queue).launch() |