Commit
·
509798f
1
Parent(s):
dadd261
cv
Browse files
app.py
CHANGED
|
@@ -55,9 +55,15 @@ def predict_disease(image):
|
|
| 55 |
Predict plant disease from uploaded image using same preprocessing as your working cv2 method
|
| 56 |
"""
|
| 57 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
# Convert PIL image to array like load_img method
|
| 59 |
-
image = image.convert("RGB") # Ensure 3 channels
|
| 60 |
-
image = image.
|
|
|
|
| 61 |
input_arr = tf.keras.preprocessing.image.img_to_array(image)
|
| 62 |
input_arr = np.array([input_arr]) # Convert single image to batch
|
| 63 |
|
|
|
|
| 55 |
Predict plant disease from uploaded image using same preprocessing as your working cv2 method
|
| 56 |
"""
|
| 57 |
try:
|
| 58 |
+
temp_path = "temp_leaf.jpg"
|
| 59 |
+
image.save(temp_path)
|
| 60 |
+
|
| 61 |
+
img = cv2.imread(temp_path)
|
| 62 |
+
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
| 63 |
# Convert PIL image to array like load_img method
|
| 64 |
+
#image = image.convert("RGB") # Ensure 3 channels
|
| 65 |
+
image = tf.keras.preprocessing.image.load_img(image_path,target_size=(128, 128))
|
| 66 |
+
#image = image.resize((128, 128)) # Resize
|
| 67 |
input_arr = tf.keras.preprocessing.image.img_to_array(image)
|
| 68 |
input_arr = np.array([input_arr]) # Convert single image to batch
|
| 69 |
|