Spaces:
Sleeping
Sleeping
SarowarSaurav
commited on
Commit
•
40b061b
1
Parent(s):
680be8b
Update app.py
Browse files
app.py
CHANGED
@@ -2,14 +2,15 @@ import gradio as gr
|
|
2 |
from transformers import pipeline
|
3 |
from PIL import Image
|
4 |
|
5 |
-
# Load a pre-trained model for plant disease classification
|
6 |
-
|
|
|
7 |
|
8 |
-
def
|
9 |
# Run the model on the image
|
10 |
results = model(image)
|
11 |
|
12 |
-
#
|
13 |
disease_name = results[0]['label']
|
14 |
confidence_score = results[0]['score']
|
15 |
|
@@ -18,15 +19,15 @@ def classify_disease(image):
|
|
18 |
|
19 |
# Create Gradio Interface
|
20 |
interface = gr.Interface(
|
21 |
-
fn=
|
22 |
inputs=gr.Image(type="pil"),
|
23 |
outputs=[
|
24 |
gr.Textbox(label="Disease Name"),
|
25 |
gr.Textbox(label="Confidence Score"),
|
26 |
gr.Image(type="pil", label="Uploaded Image")
|
27 |
],
|
28 |
-
title="
|
29 |
-
description="Upload an image of
|
30 |
)
|
31 |
|
32 |
# Launch the app
|
|
|
2 |
from transformers import pipeline
|
3 |
from PIL import Image
|
4 |
|
5 |
+
# Load a pre-trained model suitable for general plant disease classification
|
6 |
+
# Replace with an appropriate model from Hugging Face's hub trained on PlantVillage or similar
|
7 |
+
model = pipeline("image-classification", model="PlantVillage/plant-disease-model") # Replace with actual general plant disease model name if available
|
8 |
|
9 |
+
def classify_leaf_disease(image):
|
10 |
# Run the model on the image
|
11 |
results = model(image)
|
12 |
|
13 |
+
# Get the top prediction
|
14 |
disease_name = results[0]['label']
|
15 |
confidence_score = results[0]['score']
|
16 |
|
|
|
19 |
|
20 |
# Create Gradio Interface
|
21 |
interface = gr.Interface(
|
22 |
+
fn=classify_leaf_disease,
|
23 |
inputs=gr.Image(type="pil"),
|
24 |
outputs=[
|
25 |
gr.Textbox(label="Disease Name"),
|
26 |
gr.Textbox(label="Confidence Score"),
|
27 |
gr.Image(type="pil", label="Uploaded Image")
|
28 |
],
|
29 |
+
title="Leaf Disease Identification",
|
30 |
+
description="Upload an image of any plant leaf, and this model will identify the disease and show the confidence score."
|
31 |
)
|
32 |
|
33 |
# Launch the app
|