Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,9 +40,9 @@ transform = transforms.Compose([
|
|
| 40 |
class_names = ['BacterialBlights', 'Healthy', 'Mosaic', 'RedRot', 'Rust', 'Yellow']
|
| 41 |
|
| 42 |
# Function to predict disease type from an image
|
| 43 |
-
def predict_disease(
|
| 44 |
# Open the image file
|
| 45 |
-
img = Image.open(
|
| 46 |
|
| 47 |
# Apply transformations to the image
|
| 48 |
img_tensor = transform(img).unsqueeze(0) # Add batch dimension
|
|
@@ -57,7 +57,21 @@ def predict_disease(image_path):
|
|
| 57 |
|
| 58 |
return predicted_label
|
| 59 |
|
| 60 |
-
#
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
class_names = ['BacterialBlights', 'Healthy', 'Mosaic', 'RedRot', 'Rust', 'Yellow']
|
| 41 |
|
| 42 |
# Function to predict disease type from an image
|
| 43 |
+
def predict_disease(image):
|
| 44 |
# Open the image file
|
| 45 |
+
img = Image.open(image)
|
| 46 |
|
| 47 |
# Apply transformations to the image
|
| 48 |
img_tensor = transform(img).unsqueeze(0) # Add batch dimension
|
|
|
|
| 57 |
|
| 58 |
return predicted_label
|
| 59 |
|
| 60 |
+
# Gradio interface
|
| 61 |
+
inputs = gr.inputs.Image(type="pil")
|
| 62 |
+
outputs = gr.outputs.Text()
|
| 63 |
+
|
| 64 |
+
EXAMPLES = ["img1.png"]
|
| 65 |
+
|
| 66 |
+
demo_app = gr.Interface(
|
| 67 |
+
fn=predict_disease,
|
| 68 |
+
inputs=inputs,
|
| 69 |
+
outputs=outputs,
|
| 70 |
+
title="Sugarcane Disease Prediction with ViT",
|
| 71 |
+
examples=EXAMPLES,
|
| 72 |
+
live=True,
|
| 73 |
+
theme="huggingface"
|
| 74 |
+
)
|
| 75 |
+
|
| 76 |
+
demo_app.launch(debug=True, enable_queue=True)
|
| 77 |
+
|