Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def preprocess(image):
- image = cv2.resize(image, (128, 72))
- if len(image.shape) == 3 and image.shape[-1] == 3:
- image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
- image = np.expand_dims(image, -1)
- elif len(image.shape) == 3 and image.shape[-1] == 4:
- image = cv2.cvtColor(image, cv2.COLOR_RGBA2GRAY)
- image = np.expand_dims(image, -1)
- if len(image.shape) == 2:
- image = np.expand_dims(image, -1)
- return image
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement