Regino
commited on
Commit
Β·
97de020
1
Parent(s):
2763fea
shdbfsjdbf
Browse files
app.py
CHANGED
@@ -107,18 +107,34 @@ elif page == "Model Metrics":
|
|
107 |
except:
|
108 |
st.error("π¨ Model metrics files (`y_true.pth` and `y_pred.pth`) not found!")
|
109 |
|
110 |
-
|
111 |
elif page == "Disease Predictor":
|
112 |
st.title("πΏ Plant Disease Classifier")
|
113 |
-
|
114 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
uploaded_file = st.file_uploader("Upload a plant leaf image", type=["jpg", "png", "jpeg"])
|
116 |
|
117 |
if uploaded_file is not None:
|
118 |
image = Image.open(uploaded_file)
|
119 |
st.image(image, caption="Uploaded Image", use_column_width=True)
|
120 |
|
121 |
-
# Transform Image
|
122 |
transform = transforms.Compose([
|
123 |
transforms.Resize((128, 128)),
|
124 |
transforms.ToTensor(),
|
@@ -127,9 +143,10 @@ elif page == "Disease Predictor":
|
|
127 |
|
128 |
image_tensor = transform(image).unsqueeze(0)
|
129 |
|
130 |
-
# Predict Disease
|
131 |
with torch.no_grad():
|
132 |
output = model(image_tensor)
|
133 |
predicted_class = torch.argmax(output, dim=1).item()
|
134 |
|
135 |
-
st.write(f"### β
Prediction: {CLASS_NAMES[predicted_class]}")
|
|
|
|
107 |
except:
|
108 |
st.error("π¨ Model metrics files (`y_true.pth` and `y_pred.pth`) not found!")
|
109 |
|
110 |
+
## β
Disease Predictor Page
|
111 |
elif page == "Disease Predictor":
|
112 |
st.title("πΏ Plant Disease Classifier")
|
113 |
+
|
114 |
+
# β
App Overview
|
115 |
+
st.write("""
|
116 |
+
This app uses a deep learning model to detect plant diseases from leaf images.
|
117 |
+
Upload a clear image of a plant leaf, and the model will predict the disease it might have.
|
118 |
+
|
119 |
+
### π·οΈ Supported Plant Diseases:
|
120 |
+
- Early Blight
|
121 |
+
- Late Blight
|
122 |
+
- Leaf Mold
|
123 |
+
- Powdery Mildew
|
124 |
+
- Rust
|
125 |
+
- Target Spot
|
126 |
+
- Yellow Leaf Curl Virus
|
127 |
+
- Healthy (No Disease)
|
128 |
+
""")
|
129 |
+
|
130 |
+
# β
File Upload
|
131 |
uploaded_file = st.file_uploader("Upload a plant leaf image", type=["jpg", "png", "jpeg"])
|
132 |
|
133 |
if uploaded_file is not None:
|
134 |
image = Image.open(uploaded_file)
|
135 |
st.image(image, caption="Uploaded Image", use_column_width=True)
|
136 |
|
137 |
+
# β
Transform Image
|
138 |
transform = transforms.Compose([
|
139 |
transforms.Resize((128, 128)),
|
140 |
transforms.ToTensor(),
|
|
|
143 |
|
144 |
image_tensor = transform(image).unsqueeze(0)
|
145 |
|
146 |
+
# β
Predict Disease
|
147 |
with torch.no_grad():
|
148 |
output = model(image_tensor)
|
149 |
predicted_class = torch.argmax(output, dim=1).item()
|
150 |
|
151 |
+
st.write(f"### β
Prediction: **{CLASS_NAMES[predicted_class]}**")
|
152 |
+
st.success("β The prediction is based on a trained deep learning model.")
|