Load custom Data into a tensorflow pipeline

0

I am trying to implement this code which loads the data from the
official tensorflow dataset to get it to load my data placed on my google drive

dataset, metadata = tfds.load('cycle_gan/horse2zebra',
                              with_info=True, as_supervised=True)
train_horses, train_zebras = dataset['trainA'], dataset['trainB']

How can I get it to load my images into classes from classes A and B to my train_horses and train_zebras class

train_dataset=tf.keras.utils.image_dataset_from_directory(
    '/content/drive/MyDrive/ColorGan', labels='inferred', label_mode='int',
    class_names=None, color_mode='rgb', batch_size=32, image_size=(256,
    256), shuffle=True, seed=2000, validation_split=0.2, subset='training',
    interpolation='bilinear', follow_links=False,
    crop_to_aspect_ratio=False)
test_dataset=tf.keras.utils.image_dataset_from_directory(
    '/content/drive/MyDrive/ColorGan', labels='inferred', label_mode='int',
    class_names=None, color_mode='rgb', batch_size=32, image_size=(256,
    256), shuffle=True, seed=2000, validation_split=0.2, subset='validation',
    interpolation='bilinear', follow_links=False,
    crop_to_aspect_ratio=False)

train_horses, train_zebras = train_dataset['A'],train_dataset['B']

It gives me error that it is not scriptable what can I so that the data loads in the format shown in the top code snippet

You should be getting a batched dataset object, where labels are represented by integers. You cannot use square brackets to extract elements from it. That’s the meaning of “not subscriptable” error.
To see what is inside the first batch you can use a for loop:

for x, y in train_dataset.take(1):
    print('Inputs:', x, 'Labels:', y)

I’m not sure why you want to separate the classes, but it could be accomplished with a filter() function. Please, see the documentation here: tf.data.Dataset | TensorFlow Core v2.6.0

Thanks for the answer

I am trying to use this cyclegan to make color predictions of black/white images and for that
I am trying to do is to load my data into this cycle gan notebook. Also the dataset format is such it is unpaired so there is are no labels it uses unpaired examples I only have classes