Created
February 14, 2021 22:32
-
-
Save islem-esi/c9c742cd5784d90a6e65696ad65bfd38 to your computer and use it in GitHub Desktop.
prepare images for cnn
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 keras | |
| from keras.models import Sequential | |
| from keras.layers import Dense, Dropout, Activation, Flatten | |
| from keras.layers import Conv2D, MaxPooling2D | |
| import numpy as np | |
| #reshape images to fit into the CNN model | |
| img_list = np.zeros(shape = (len(images), h,w,1), dtype = np.uint8) | |
| for j in range(len(images)): | |
| img_list[j,:,:,0] = np.reshape(list(images[j]), (h,w)) | |
| img_list = img_list.astype('float32') | |
| img_list /= 255 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment