Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ from transformers import pipeline
|
|
| 3 |
from PIL import Image
|
| 4 |
|
| 5 |
# Load a pre-trained model for plant disease classification
|
| 6 |
-
model = pipeline("image-classification", model="microsoft/resnet-50") #
|
| 7 |
|
| 8 |
def classify_disease(image):
|
| 9 |
# Run the model on the image
|
|
@@ -14,20 +14,16 @@ def classify_disease(image):
|
|
| 14 |
confidence_score = results[0]['score']
|
| 15 |
|
| 16 |
# Format the output
|
| 17 |
-
return {
|
| 18 |
-
"Disease Name": disease_name,
|
| 19 |
-
"Confidence Score": f"{confidence_score:.2f}",
|
| 20 |
-
"Uploaded Image": image
|
| 21 |
-
}
|
| 22 |
|
| 23 |
# Create Gradio Interface
|
| 24 |
interface = gr.Interface(
|
| 25 |
fn=classify_disease,
|
| 26 |
-
inputs=gr.
|
| 27 |
outputs=[
|
| 28 |
-
gr.
|
| 29 |
-
gr.
|
| 30 |
-
gr.
|
| 31 |
],
|
| 32 |
title="Tobacco Plant Disease Identification",
|
| 33 |
description="Upload an image of a tobacco plant leaf, and this model will identify the disease and show the confidence score."
|
|
|
|
| 3 |
from PIL import Image
|
| 4 |
|
| 5 |
# Load a pre-trained model for plant disease classification
|
| 6 |
+
model = pipeline("image-classification", model="microsoft/resnet-50") # Replace with a specific plant disease model if available on Hugging Face
|
| 7 |
|
| 8 |
def classify_disease(image):
|
| 9 |
# Run the model on the image
|
|
|
|
| 14 |
confidence_score = results[0]['score']
|
| 15 |
|
| 16 |
# Format the output
|
| 17 |
+
return disease_name, f"{confidence_score:.2f}", image
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
# Create Gradio Interface
|
| 20 |
interface = gr.Interface(
|
| 21 |
fn=classify_disease,
|
| 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="Tobacco Plant Disease Identification",
|
| 29 |
description="Upload an image of a tobacco plant leaf, and this model will identify the disease and show the confidence score."
|