Hi,
I am trying to create a dataset class for a problem, In that all the targets are in the form of a string like “Airplane”, “tree” etc. When I am trying to convert it into a tensor is says that TypeError: must be real number, not string, also when I am trying to convert image to tensor it says TypeError: must be real number, not JpegImageFile.
Here is my code:
class HolidayDataset(Dataset):
    def __init__(self, df, transform=None):
        self.df = df
        self.transforms = transform
        
    def __len__(self):
        return len(self.df)
    
    def __getitem__(self, idx):
        img_name = 'Input/dataset/train/' + self.df.Image[idx]
        target = self.df.Class[idx]
        img = Image.open(img_name)
        if self.transforms:
            img = self.transforms(img)
        return {
            "img": torch.tensor(img, dtype=torch.float),
            "target": torch.tensor(target, dtype=torch.float)
        }