Getting _labels from the test_set

Can anyone tell me how to get the labels of the test set that I have after image data generator .
i need the labels to plot the confusion matrix. Please mentors tell me how to plot the confusion matrix.

test_datagen = ImageDataGenerator(rescale = 1./255,validation_split = 0.1)

test_set = val_datagen.flow_from_directory(val_path,
target_size = (227,227),
batch_size = 16,
class_mode = “categorical”

                                      )

model.evaluate(test_set)
y_pred = model.predict(test_set)

for plotting confusion matrix I can use this function:
tf.math.confusion_matrix(
labels,
predictions,
num_classes=None,
weights=None,
dtype=tf.dtypes.int32,
name=None
)

but how do I get the labels to feed in the above function

Use image_generator.class_indices. Here’s an example:
image

It is giving me an error . please can you give me the detailed code . I am new in tensorflow , please help me

Open TF1 course 2 week 1 assignment notebook.
Once you fill code till train_val_generators, the next cell invokes the function to get both training and validation generators.

See the cell below expected output (added for your understanding). The mapping from string labels of class to the corresponding integer representation is printed out.