Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from fastai.vision.all import * | |
| import skimage | |
| learn = load_learner('model.pkl') | |
| labels = learn.dls.vocab | |
| categories = ('diffenbachia', 'spider', 'monstera') | |
| 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 = "Plant Classifier Classifier" | |
| description = "A plant classifier I made with with fastai. Created as a demo for Gradio and HuggingFace Spaces." | |
| interpretation='default' | |
| examples = [ | |
| ["images/diffenbachia.jpg"], | |
| ["images/spider.jpg"], | |
| ["images/monstera.jpg"] | |
| ] | |
| article="<p style='text-align: center'><a href='https://lucasgelfond.substack.com/p/fastai-lesson-2-deployment' target='_blank'>Blog post</a></p>" | |
| enable_queue=True | |
| iface = gr.Interface(fn=predict, inputs="image", outputs="label") | |
| iface.launch() |