VCardWizard / app.py
SarowarSaurav's picture
Update app.py
ba2ce75 verified
raw
history blame
1.16 kB
import gradio as gr
from transformers import pipeline
from PIL import Image
# Load the Hugging Face image classification pipeline with EfficientNetB0
# This model is a general-purpose model for plant disease classification
classifier = pipeline("image-classification", model="nateraw/efficientnet-b0")
def identify_disease(image):
# Use the classifier to predict the disease
predictions = classifier(image)
# Format the output to include disease name and confidence score
results = [{"Disease": pred["label"], "Confidence": f"{pred['score'] * 100:.2f}%"} for pred in predictions]
# Return the uploaded image along with the results
return image, results
# Define Gradio interface
interface = gr.Interface(
fn=identify_disease,
inputs=gr.inputs.Image(type="pil"),
outputs=[
gr.outputs.Image(type="pil", label="Uploaded Image"),
gr.outputs.Dataframe(type="pandas", label="Predictions")
],
title="Plant Disease Identifier",
description="Upload an image of a plant leaf, and this tool will identify the disease along with the confidence score."
)
# Launch the app
interface.launch()