-
-
Save jurand71/b5d17b599a1c0c6ad220a9067fa090e4 to your computer and use it in GitHub Desktop.
This file contains 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
def prepare_image_Xy(df): | |
train_image_X = [] | |
train_image_y = [] | |
for n in range(len(df) - 1): | |
img = cv2.imread(str(df.iloc[n].path), cv2.IMREAD_GRAYSCALE) | |
height, width = img.shape | |
ratio = float(height/width) | |
if ratio > 0.6: | |
img_pred = cv2.resize(img, (81,81), interpolation=cv2.INTER_AREA) | |
img_pred = img_to_array(img_pred) | |
img_pred = img_pred / 255 | |
train_image_X.append(img_pred) | |
train_image_y.append(df.iloc[n].label) | |
X = np.array(train_image_X) | |
y = np.array(train_image_y) | |
return X,y | |
X_train, y_train = prepare_image_Xy(train) | |
X_test, y_test = prepare_image_Xy(test) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment