amirkhanbloch commited on
Commit
8e813dd
·
verified ·
1 Parent(s): 8fb77ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -80
app.py CHANGED
@@ -1,4 +1,3 @@
1
- import streamlit as st
2
  import cv2
3
  import numpy as np
4
  import tensorflow as tf
@@ -92,84 +91,6 @@ treatment_dict = {
92
  }
93
  }
94
 
95
- # Crop disease dictionary
96
- crop_disease_dict = {
97
- "Wheat": [
98
- "Rust", "Powdery Mildew", "Fusarium Head Blight", "Septoria Leaf Blotch",
99
- "Barley Yellow Dwarf", "Leaf Spot", "Bacterial Blight", "Loose Smut",
100
- "Sharp Eyespot", "Root Rot", "Take-all", "Yellow Rust", "Brown Rust",
101
- "Black Point", "Stem Rust", "Glume Blotch", "Dwarf Wheat Rust", "Wheat Blast"
102
- ],
103
- "Rice": [
104
- "Brown Spot", "Leaf Blast", "Bacterial Blight", "Sheath Blight",
105
- "Rice Tungro Virus", "False Smut", "Leaf Scald", "Stem Rot",
106
- "Glume Discoloration", "Narrow Brown Leaf Spot", "Mosaic Virus",
107
- "Ricelblast", "White Tip", "Bacterial Leaf Blight", "Fusarium Head Blight"
108
- ],
109
- "Corn": [
110
- "Corn Smut", "Northern Corn Leaf Blight", "Gray Leaf Spot", "Goss's Wilt",
111
- "Southern Rust", "Common Rust", "Seedling Blight", "Ear Rot",
112
- "Fusarium Ear Rot", "Anthracnose", "Bacterial Leaf Streak", "Diplodia Ear Rot",
113
- "Eyespot", "Root Rot", "Crown Rot", "Stalk Rot", "Kernel Rot"
114
- ],
115
- "Soybean": [
116
- "Soybean Cyst Nematode", "Phytophthora Root Rot", "Bacterial Blight", "Downy Mildew",
117
- "Brown Spot", "Sclerotinia Stem Rot", "Frogeye Leaf Spot", "Pod Blight",
118
- "Root Rot", "Anthracnose", "Virus Diseases", "Septoria Leaf Spot",
119
- "Rust", "White Mold", "Sudden Death Syndrome", "Charcoal Rot"
120
- ],
121
- "Tomato": [
122
- "Late Blight", "Early Blight", "Leaf Spot", "Fusarium Wilt",
123
- "Bacterial Spot", "Blossom End Rot", "Powdery Mildew", "Septoria Leaf Spot",
124
- "Tobacco Mosaic Virus", "Gray Mold", "Canker", "Phytophthora Root Rot",
125
- "Verticillium Wilt", "Downy Mildew", "Black Mold", "Nematode Infestation"
126
- ],
127
- "Potato": [
128
- "Late Blight", "Early Blight", "Black Leg", "Scab",
129
- "Powdery Scab", "Fusarium Wilt", "Tuber Blight", "Soft Rot",
130
- "Verticillium Wilt", "Phytophthora Blight", "Golden Nematode",
131
- "Bacterial Ring Rot", "Leaf Roll Virus", "Potato Virus X", "Cyst Nematodes"
132
- ],
133
- "Cotton": [
134
- "Cotton Wilt", "Boll Rot", "Alternaria Leaf Spot", "Bacterial Blight",
135
- "Fusarium Wilt", "Pink Bollworm", "Cotton Leaf Curl Virus", "Root Knot Nematode",
136
- "Seedling Disease", "Boll Weevil", "Leaf Spot", "Webworm",
137
- "Southern Blight", "Target Spot", "Anthracnose", "Thrips Damage"
138
- ],
139
- "Barley": [
140
- "Barley Yellow Dwarf", "Powdery Mildew", "Net Blotch", "Fusarium Head Blight",
141
- "Scald", "Hulled Barley Disease", "Root Rot", "Bacterial Leaf Blight",
142
- "Corn Smut", "Kernel Blight", "Mosaic Virus", "Spot Blotch",
143
- "Streak", "Barley Yellow Mosaic"
144
- ],
145
- "Cabbage": [
146
- "Black Rot", "Downy Mildew", "Cabbage Looper", "Alternaria Leaf Spot",
147
- "Clubroot", "Bacterial Soft Rot", "Fusarium Wilt", "Cabbage Maggot",
148
- "Diamondback Moth", "Bacterial Blight", "Mosaic Virus", "White Rust",
149
- "Leaf Spot", "Sclerotinia Rot"
150
- ],
151
- "Carrot": [
152
- "Alternaria Leaf Blight", "Cavity Spot", "Fusarium Wilt", "Bacterial Soft Rot",
153
- "Downy Mildew", "Carrot Rust Fly", "Crown Rot", "Powdery Mildew",
154
- "Bacterial Blight", "Sclerotinia Rot", "Root Knot Nematode", "Mosaic Virus",
155
- "Leaf Spot"
156
- ],
157
- "Onion": [
158
- "Downy Mildew", "Onion Fly", "White Rot", "Botrytis Leaf Blight",
159
- "Fusarium Basal Rot", "Bacterial Soft Rot", "Pink Root", "Mosaic Virus",
160
- "Leaf Blight", "Pythium Root Rot", "Black Mold", "Fusarium Wilt"
161
- ],
162
- "Grapes": [
163
- "Powdery Mildew", "Downy Mildew", "Botrytis Bunch Rot", "Black Rot",
164
- "Phomopsis Cane and Leaf Spot", "Crown Gall", "Pierce's Disease",
165
- "Bacterial Blight", "Eutypa Dieback", "Grapevine Leafroll",
166
- "Sooty Mold", "Anthracnose", "Mealybug Infestation", "Fungal Leaf Spot"
167
- ],
168
- "Peppers": [
169
- "Bacterial Spot", "Powdery Mildew", "Phytophthora Blight", "Blossom End Rot",
170
- "Pepper Weevil", "Fusarium Wilt", "Downy
171
-
172
- ]
173
  def preprocess_image(image, image_size=(224, 224)):
174
  # Convert image to grayscale
175
  image = np.array(image.convert('L'))
@@ -201,6 +122,11 @@ if uploaded_file is not None:
201
  predictions = model.predict(processed_image)
202
  probabilities = predictions[0]
203
 
 
 
 
 
 
204
  # Show predicted class
205
  predicted_class = class_labels[np.argmax(probabilities)]
206
  st.write(f"Classe prédite: {predicted_class}")
@@ -212,4 +138,4 @@ if uploaded_file is not None:
212
  if treatment_info['medicines']:
213
  st.write("Médicaments recommandés:", ', '.join(treatment_info['medicines']))
214
  else:
215
- st.write("Aucun médicament requis.")
 
 
1
  import cv2
2
  import numpy as np
3
  import tensorflow as tf
 
91
  }
92
  }
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  def preprocess_image(image, image_size=(224, 224)):
95
  # Convert image to grayscale
96
  image = np.array(image.convert('L'))
 
122
  predictions = model.predict(processed_image)
123
  probabilities = predictions[0]
124
 
125
+ # Display probabilities for each class
126
+ for i, label in enumerate(class_labels):
127
+ if probabilities[i] > 0:
128
+ st.write(f"{label}: {probabilities[i]:.2f}")
129
+
130
  # Show predicted class
131
  predicted_class = class_labels[np.argmax(probabilities)]
132
  st.write(f"Classe prédite: {predicted_class}")
 
138
  if treatment_info['medicines']:
139
  st.write("Médicaments recommandés:", ', '.join(treatment_info['medicines']))
140
  else:
141
+ st.write("Aucun médicament requis.")