VCardWizard / app.py
SarowarSaurav's picture
Update app.py
40b061b verified
raw
history blame
1.21 kB
import gradio as gr
from transformers import pipeline
from PIL import Image
# Load a pre-trained model suitable for general plant disease classification
# Replace with an appropriate model from Hugging Face's hub trained on PlantVillage or similar
model = pipeline("image-classification", model="PlantVillage/plant-disease-model") # Replace with actual general plant disease model name if available
def classify_leaf_disease(image):
# Run the model on the image
results = model(image)
# Get the top prediction
disease_name = results[0]['label']
confidence_score = results[0]['score']
# Format the output
return disease_name, f"{confidence_score:.2f}", image
# Create Gradio Interface
interface = gr.Interface(
fn=classify_leaf_disease,
inputs=gr.Image(type="pil"),
outputs=[
gr.Textbox(label="Disease Name"),
gr.Textbox(label="Confidence Score"),
gr.Image(type="pil", label="Uploaded Image")
],
title="Leaf Disease Identification",
description="Upload an image of any plant leaf, and this model will identify the disease and show the confidence score."
)
# Launch the app
if __name__ == "__main__":
interface.launch()