| import cv2 | |
| import numpy as np | |
| def preprocess_image(image): | |
| image = np.array(image) | |
| image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY) | |
| image = cv2.resize(image, (224, 224)) | |
| image = image / 255.0 | |
| image = image.reshape(1, 224, 224, 1) | |
| return image |
| import cv2 | |
| import numpy as np | |
| def preprocess_image(image): | |
| image = np.array(image) | |
| image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY) | |
| image = cv2.resize(image, (224, 224)) | |
| image = image / 255.0 | |
| image = image.reshape(1, 224, 224, 1) | |
| return image |