Skip to content

Instantly share code, notes, and snippets.

@CleanPegasus
Created September 28, 2020 07:53
Show Gist options
  • Save CleanPegasus/46998355ba3d365c135aad5c418c2d10 to your computer and use it in GitHub Desktop.
Save CleanPegasus/46998355ba3d365c135aad5c418c2d10 to your computer and use it in GitHub Desktop.
Preprocessing the image before predicting
img = cv2.imread('img.jpg') # reading the image
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # converting the image to grayscale
img = cv2.resize(img, (48, 48)) # resizing the image
img = img/255 # normalizing the image
img = np.reshape(img, [-1, 48, 48, 1]) # reshaping the image to be suitable for serving
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment