Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. def preprocess(image):
  2. image = cv2.resize(image, (128, 72))
  3. if len(image.shape) == 3 and image.shape[-1] == 3:
  4. image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
  5. image = np.expand_dims(image, -1)
  6. elif len(image.shape) == 3 and image.shape[-1] == 4:
  7. image = cv2.cvtColor(image, cv2.COLOR_RGBA2GRAY)
  8. image = np.expand_dims(image, -1)
  9. if len(image.shape) == 2:
  10. image = np.expand_dims(image, -1)
  11. return image
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement