Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Images
train_images = df_train.loc[:,'image_name']
train_labels = df_train.loc[:,'category']
test_images = df_test.loc[:,'image_name']
test_labels = df_test.loc[:,'category']
# Train images
x_train = []
for i in train_images:
image = home_path+'/images/'+i
img = cv2.imread(image)
x_train.append(img)
# Train labels
y_train=keras.utils.to_categorical(train_labels)
# Test images
x_test = []
for i in test_images:
image = home_path+'/images/'+i
img = cv2.imread(image)
x_test.append(img)
# Test labels
y_test=keras.utils.to_categorical(test_labels)
# Normalize images
x_train = np.array(x_train, dtype="float") / 255.0
x_test = np.array(x_test, dtype="float") / 255.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment