Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -28,6 +28,70 @@ class_labels = [
|
|
28 |
'Tomate: Healthy'
|
29 |
]
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
def preprocess_image(image, image_size=(224, 224)):
|
32 |
# Convert image to grayscale
|
33 |
image = np.array(image.convert('L'))
|
@@ -66,4 +130,13 @@ if uploaded_file is not None:
|
|
66 |
|
67 |
# Show predicted class
|
68 |
predicted_class = class_labels[np.argmax(probabilities)]
|
69 |
-
st.write(f"Classe prédite: {predicted_class}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
'Tomate: Healthy'
|
29 |
]
|
30 |
|
31 |
+
# Treatment dictionary mapping disease classes to treatment options
|
32 |
+
treatment_dict = {
|
33 |
+
'Piment: Bacterial_spot': {
|
34 |
+
'treatment': 'Apply Copper Fungicide',
|
35 |
+
'medicines': ['Fungicide A', 'Fungicide B']
|
36 |
+
},
|
37 |
+
'Piment: healthy': {
|
38 |
+
'treatment': 'No treatment required',
|
39 |
+
'medicines': []
|
40 |
+
},
|
41 |
+
'Pomme de terre: Early_blight': {
|
42 |
+
'treatment': 'Use Neem Oil',
|
43 |
+
'medicines': ['Neem Oil', 'Fungicide C']
|
44 |
+
},
|
45 |
+
'Pomme de terre: Late_blight': {
|
46 |
+
'treatment': 'Apply Systemic Fungicide',
|
47 |
+
'medicines': ['Fungicide D']
|
48 |
+
},
|
49 |
+
'Pomme de terre: Healthy': {
|
50 |
+
'treatment': 'No treatment required',
|
51 |
+
'medicines': []
|
52 |
+
},
|
53 |
+
'Tomate: Bacterial Spot': {
|
54 |
+
'treatment': 'Remove infected leaves and apply bactericide',
|
55 |
+
'medicines': ['Bactericide A']
|
56 |
+
},
|
57 |
+
'Tomate: Early Blight': {
|
58 |
+
'treatment': 'Apply preventative fungicides',
|
59 |
+
'medicines': ['Fungicide E']
|
60 |
+
},
|
61 |
+
'Tomate: Late Blight': {
|
62 |
+
'treatment': 'Use fungicides with metalaxyl',
|
63 |
+
'medicines': ['Fungicide F']
|
64 |
+
},
|
65 |
+
'Tomate: Leaf mold': {
|
66 |
+
'treatment': 'Improve air circulation',
|
67 |
+
'medicines': ['Fungicide G']
|
68 |
+
},
|
69 |
+
'Tomate: Septoria leaf spot': {
|
70 |
+
'treatment': 'Remove infected leaves and spray with fungicide',
|
71 |
+
'medicines': ['Fungicide H']
|
72 |
+
},
|
73 |
+
'Tomate: Spider mites': {
|
74 |
+
'treatment': 'Use miticides or insecticidal soap',
|
75 |
+
'medicines': ['Miticide A']
|
76 |
+
},
|
77 |
+
'Tomate: Spot': {
|
78 |
+
'treatment': 'Check for pest issues and apply appropriate treatment',
|
79 |
+
'medicines': []
|
80 |
+
},
|
81 |
+
'Tomate: Yellow Leaf Curl': {
|
82 |
+
'treatment': 'Remove infected plants',
|
83 |
+
'medicines': []
|
84 |
+
},
|
85 |
+
'Tomate: Virus Mosaïque': {
|
86 |
+
'treatment': 'Remove infected plants',
|
87 |
+
'medicines': []
|
88 |
+
},
|
89 |
+
'Tomate: Healthy': {
|
90 |
+
'treatment': 'No treatment required',
|
91 |
+
'medicines': []
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
def preprocess_image(image, image_size=(224, 224)):
|
96 |
# Convert image to grayscale
|
97 |
image = np.array(image.convert('L'))
|
|
|
130 |
|
131 |
# Show predicted class
|
132 |
predicted_class = class_labels[np.argmax(probabilities)]
|
133 |
+
st.write(f"Classe prédite: {predicted_class}")
|
134 |
+
|
135 |
+
# Display treatment information
|
136 |
+
if predicted_class in treatment_dict:
|
137 |
+
treatment_info = treatment_dict[predicted_class]
|
138 |
+
st.write("Traitement recommandé:", treatment_info['treatment'])
|
139 |
+
if treatment_info['medicines']:
|
140 |
+
st.write("Médicaments recommandés:", ', '.join(treatment_info['medicines']))
|
141 |
+
else:
|
142 |
+
st.write("Aucun médicament requis.")
|