Issue with this line class_name = get_label_name(path), you are trying to get the class_name but its giving Tensor value. It should be list of classes.
Find the below working code,

import os
os.environ[‘TF_CPP_MIN_LOG_LEVEL’] = ‘2’
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
import pandas as pd
from tensorflow.keras import datasets, layers
from glob import glob
from tensorflow.keras.preprocessing.image import ImageDataGenerator
train_paths = glob(‘dataset/cifar/train/.png’)
test_paths = glob('dataset/cifar/train/.png’)
def get_label_name (path):
lbl_name = path.split(’/’)[-1].replace(’.png’,’’)
return lbl_name
classes = np.unique([get_label_name (path) for path in train_paths])
classes
def onehot_encoding(label_name):
onehot_encoding = tf.cast(classes == label_name, tf.uint8)
return onehot_encoding
def read_dataset(path):
gfile = tf.io.read_file(path)
image = tf.io.decode_image(gfile)
    class_name = [get_label_name (path) for path in train_paths]
    label = onehot_encoding(class_name)
    return image, label

train_dataset = tf.data.Dataset.from_tensor_slices(train_paths)
train_dataset = train_dataset.map(read_dataset)
train_dataset = train_dataset.batch(batch_size=32)
train_dataset = train_dataset.shuffle(buffer_size=len(train_paths))
train_dataset = train_dataset.repeat()