Skip to content

Instantly share code, notes, and snippets.

@HSShashank
Created August 25, 2021 05:27
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 HSShashank/a9ad80e0f5d5d31199101a88e4742ce6 to your computer and use it in GitHub Desktop.
Save HSShashank/a9ad80e0f5d5d31199101a88e4742ce6 to your computer and use it in GitHub Desktop.
X_data = df['IMAGE PATH']
y_data = df['MAPPED LABELS']
X_train, X_test, y_train, y_test = train_test_split(X_data, y_data, shuffle=True, test_size=0.01,stratify=y_data)
#Creating numpy arrays of images
X = []
y = []
for i in X_train:
X.append(cv2.imread(i))
for i in y_train:
y.append(i)
X = np.array(X)
y = np.array(y)
# Converting the labels vector to one-hot format
y = keras.utils.to_categorical(y, 5)
print(f"Total number of Images: {len(X_data)}")
print(f"Number of Training Images: {len(X_train)}")
print(f"Number of Test Images: {len(X_test)}") # Saving a small number of images for model testing|
print(f"Shape of Images: {X[0].shape}") #Printing the shape of Images
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment