Skip to content

Instantly share code, notes, and snippets.

@aniruddha27
Last active August 8, 2020 06:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aniruddha27/aa383f05cc45f517a79a1b6ec3bfdcf5 to your computer and use it in GitHub Desktop.
Save aniruddha27/aa383f05cc45f517a79a1b6ec3bfdcf5 to your computer and use it in GitHub Desktop.
# 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