Created
September 20, 2019 08:56
-
-
Save dipanjanS/c5b61c7520b5c4273245f5882f6190ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
def resize_image_array(img, img_size_dims): | |
img = cv2.resize(img, dsize=img_size_dims, | |
interpolation=cv2.INTER_CUBIC) | |
img = np.array(img, dtype=np.float32) | |
return img | |
# convert single channel images to 3-channel images | |
train_images_3ch = np.stack([train_images]*3, axis=-1) | |
test_images_3ch = np.stack([test_images]*3, axis=-1) | |
# resizing images | |
IMG_DIMS = (32, 32) | |
train_images_3ch = np.array([resize_image_array(img, img_size_dims=IMG_DIMS) for img in train_images_3ch]) | |
test_images_3ch = np.array([resize_image_array(img, img_size_dims=IMG_DIMS) for img in test_images_3ch]) | |
print('\nTrain_images.shape: {}, of {}'.format(train_images_3ch.shape, train_images_3ch.dtype)) | |
print('Test_images.shape: {}, of {}'.format(test_images_3ch.shape, test_images_3ch.dtype)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment