I am writing custom dataset but it returns type error when I am merging root directory path with pandas iloc of image name in csv file:
 img_path = os.path.join(self.root_dir, self.annotations.iloc[index,0])

error:  TypeError: join() argument must be str or bytes, not 'int64'
I have tried converting the annotation.iloc to string type but it’s still giving me the same error.
custom dataset class:
class patientdataset(Dataset):

    def __init__(self, csv_file, root_dir, transform=None):  
            self.annotations = pd.read_csv(csv_file)
            self.root_dir = root_dir
            self.transform = transform



    def __len__(self):
        return len(self.annotations)

    def __getitem__(self, index):
        img_path = os.path.join(self.root_dir, self.annotations.iloc[index,0])  
        image= np.array(np.load(img_path)) 
        y_label = torch.tensor(self.annotations.iloc[index, 1]).long()


        if self.transform:
            imagearrays = self.transform(image)
            image = imagearrays[None, :, :, :]
            imaget = np.transpose(image, (0, 2, 1, 3))
            image = imaget


        return (image, y_label)

CSV file with image names and labels
CSV file with image names and labels179×698 5.27 KB