Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from fastai.vision.all import * | |
| from huggingface_hub import from_pretrained_fastai | |
| repo_id = "kurianbenoy/paddy_convnext_model" | |
| learn = from_pretrained_fastai(repo_id) | |
| labels = learn.dls.vocab | |
| def predict(img): | |
| img = PILImage.create(img) | |
| _pred, _pred_w_idx, probs = learn.predict(img) | |
| # gradio doesn't support tensors, so converting to float | |
| labels_probs = {labels[i]: float(probs[i]) for i, _ in enumerate(labels)} | |
| return labels_probs | |
| interface_options = { | |
| "title": "Paddy Doctor", | |
| "description": "Paddy cultivation requires consistent supervision because several diseases and pests might affect the paddy crops, leading to up to 70% yield loss. This spaces is an online demo to showcase a model build for [real-world Kaggle competition](https://www.kaggle.com/competitions/paddy-disease-classification/overview) to identify diseases from images of paddy leaves.", | |
| "interpretation": "default", | |
| "layout": "horizontal", | |
| # Audio from validation file | |
| "examples": [ | |
| "100098.jpg", | |
| "100002.jpg", | |
| "100048.jpg" | |
| ], | |
| "allow_flagging": "never", | |
| } | |
| demo = gr.Interface( | |
| fn=predict, | |
| inputs=gr.inputs.Image(shape=(480, 480)), | |
| outputs=gr.outputs.Label(num_top_classes=3), | |
| **interface_options, | |
| ) | |
| launch_options = { | |
| "enable_queue": True, | |
| "share": False, | |
| } | |
| demo.launch(**launch_options) | |