How to load a subset of classes using ImageDataGenerator?

I wanted to load only few classes from caltech256 dataset, and since the number of classes will change with each experiment, I wont be able to do it manually i was wondering if there is a way in ImageDataGenerator of tensorlflow which would allow me to do so What I did so far is this

from google.colab import drive

import pathlib
data = pathlib.Path('/content/gdrive/My Drive/Data_Clatech256/2_categ_caltech') 

from keras.preprocessing.image import ImageDataGenerator

train_datagen = ImageDataGenerator(
test_datagen = ImageDataGenerator(rescale=1./255)

train_generator = train_datagen.flow_from_directory(
        target_size=(150, 150),
        class_mode = "categorical"

All the efforts are appreciated


Maybe the ‘classes’ parameter is what you need, Follow this source code link , it shows us the classes is used to list what we want. And flow_from_directory function shows us a argument named classes

    directory, target_size=(256, 256), color_mode='rgb', classes=None,
    class_mode='categorical', batch_size=32, shuffle=True, seed=None,
    save_to_dir=None, save_prefix='', save_format='png',
    follow_links=False, subset=None, interpolation='nearest'