I have a tf dataset called train_ds:
directory = 'Data/dataset_train'
train_ds = tf.keras.preprocessing.image_dataset_from_directory(
directory,
validation_split=0.2,
subset="training",
color_mode='grayscale',
seed=123,
image_size=(28, 28),
batch_size=32)
This dataset is composed of 20000 images of "Fake" images and 20000 "Real" images and I want to extract X_train and y_train in numpy form from this tf dataset but I have only managed to get the labels out with
y_train = np.concatenate([y for x, y in train_ds], axis=0)
I also tried with this but it doesn't seem like it's iterating through the 20000 images:
for images, labels in train_ds.take(-1):
X_train = images.numpy()
y_train = labels.numpy()
I really want to extract the images to X_train and the labels to y_train but I can't figure it out! I apologize in advance for any mistake I've made and appreciate all the help I can get :)