Custom label with image_dataset_from_directory

I wanted to change label from multi class to binary class (0,1) eg. class 1 or the rest. Is there any way to change the label with tf.keras.utils.image_dataset_from_directory
My image are in structure like this
class 1
image1
image2

class 2
image1
image2


class 100
image1
image2

my code:

train_dataset = tf.keras.utils.image_dataset_from_directory(train_dir,
shuffle=False,
batch_size=batch_size,
image_size=imgage_size,
labels = ‘inferred’,
seed = 1
)

Hi @pupu, Generally image_dataset_from_directory loads the data based on the directory structure. while loading the multi class data I don’t think it is possible to convert that to a binary class. One way is to rearrange the directory structure having 2 classes. Thank You.