CZerion's picture
Update app.py
4994fc9 verified
import os
import gradio as gr
from inference.inference import load_disease_pipeline, diagnose
"""
Step 5: Gradio demo for disease-only model with example images
"""
# load your published model or local checkpoint
pipe = load_disease_pipeline("linkanjarad/mobilenet_v2_1.0_224-plant-disease-identification")
# Path to examples folder
examples = [
["Plants/Unhealthy_crop_1.jpg"],
["Plants/Unhealthy_crop_2.jpg"],
["Plants/Unhealthy_crop_3.jpg"],
["Plants/Unhealthy_crop_4.jpg"],
["Plants/Unhealthy_crop_5.jpg"],
["Plants/Healthy_crop_1.jpg"],
["Plants/Healthy_crop_2.jpg"]
]
iface = gr.Interface(
fn=lambda img: diagnose(img, pipe),
inputs=gr.Image(type="pil", label="Upload Leaf Image"),
outputs=[
gr.Textbox(label="Disease Predictions (Top 3)"),
gr.Textbox(label="Care Advice")
],
title="Plant Disease Monitor",
description="Upload a crop leaf photo to detect diseases using a fine-tuned model.",
examples=examples,
allow_flagging="never"
)
if __name__ == "__main__":
iface.launch()