I also got the same error when I was training an Image classification model with a reference-style image dataset. Here I implemented a Custom Dataset Class by extending from torch.utils.data import Dataset
class. Same as you I haven't encoded my target labels and they are just a tuple of class names(strings). Since PyTorch tensors don't accept string data directly, I had to convert these labels into integer-encoded tensors before using them in model training.