amirkhanbloch commited on
Commit
eddad31
·
verified ·
1 Parent(s): 5a3abe9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +75 -43
app.py CHANGED
@@ -92,46 +92,78 @@ treatment_dict = {
92
  }
93
  }
94
 
95
- def preprocess_image(image, image_size=(224, 224)):
96
- # Convert image to grayscale
97
- image = np.array(image.convert('L'))
98
- # Resize image
99
- image = cv2.resize(image, image_size)
100
- # Prepare image for the model
101
- image = img_to_array(image)
102
- image /= 255.0
103
- image = np.expand_dims(image, axis=0)
104
- return image
105
-
106
- # Streamlit app setup
107
- st.title("Classification des Maladies des Plantes")
108
- st.write("Téléchargez une image de plante pour la classification")
109
-
110
- uploaded_file = st.file_uploader("Choisissez une image...", type=["jpg", "jpeg", "png"])
111
-
112
- if uploaded_file is not None:
113
- # Display the uploaded image
114
- image = Image.open(uploaded_file)
115
- st.image(image, caption='Image téléchargée', use_column_width=True)
116
-
117
- st.write("Classification en cours...")
118
-
119
- # Preprocess the image
120
- processed_image = preprocess_image(image)
121
-
122
- # Make predictions
123
- predictions = model.predict(processed_image)
124
- probabilities = predictions[0]
125
-
126
- # Show predicted class
127
- predicted_class = class_labels[np.argmax(probabilities)]
128
- st.write(f"Classe prédite: {predicted_class}")
129
-
130
- # Display treatment information
131
- if predicted_class in treatment_dict:
132
- treatment_info = treatment_dict[predicted_class]
133
- st.write("Traitement recommandé:", treatment_info['treatment'])
134
- if treatment_info['medicines']:
135
- st.write("Médicaments recommandés:", ', '.join(treatment_info['medicines']))
136
- else:
137
- st.write("Aucun médicament requis.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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", "Ph