Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from fastai.vision.all import * | |
| import skimage | |
| learn = load_learner("model.pkl") | |
| labels = learn.dls.vocab | |
| def classify_garbage(img): | |
| img = PILImage.create(img) | |
| pred,idx,probs = learn.predict(img) | |
| return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
| image = gr.inputs.Image(shape = (128,128)) | |
| label = gr.outputs.Label(num_top_classes=7) | |
| title = "Garbage Classifier" | |
| description = "A Garbage classifier trained with fastai. Created as a demo for Gradio and HuggingFace Spaces." | |
| examples = ['paper24.jpg'] | |
| interpretation='default' | |
| enable_queue=True | |
| iface = gr.Interface(fn=classify_garbage, inputs=image, outputs=label,examples=examples,title=title,description=description,interpretation=interpretation,enable_queue=enable_queue) | |
| iface.launch(inline=False) |