Last active
August 13, 2019 20:01
-
-
Save techwithshadab/449f2e10b3a3ff53cebdc5e1c1d645c4 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
# preparing data by processing images using opencv | |
ROWS = 64 | |
COLS = 64 | |
CHANNELS = 3 | |
def read_image(file_path): | |
img = cv2.imread(file_path, cv2.IMREAD_COLOR) #cv2.IMREAD_GRAYSCALE | |
return cv2.resize(img, (ROWS, COLS), interpolation=cv2.INTER_CUBIC) | |
def prep_data(images): | |
count = len(images) | |
data = np.ndarray((count, CHANNELS, ROWS, COLS), dtype=np.uint8) | |
for i, image_file in enumerate(images): | |
image = read_image(image_file) | |
data[i] = image.T | |
if i%5 == 0: print('Processed {} of {}'.format(i, count)) | |
return data | |
train = prep_data(train_image_name) | |
test = prep_data(test_image_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment