I am trying to create my own custom dataset to train a CNN.My dataset has images and corresponding annotations.
The code is as follows:

import ...

annotation=...
 
class Data(Dataset):
#    def _init_(self, annotation , root_dir , transform=None):   
    def __init__(self, root_dir,annotation):   
        self.annotations = annotation
        self.root_dir = ...
        
    def __len__(self):
        return len(self.annotations[0,:])
    
    def __getitem__(self,idx):
        image_name = ..
        image_mat = scipy.io.loadmat(voxel_name) #images are saved as mat files                                                
        image=torch.from_numpy(image_mat)
        annotation = ...
        return image, annotation 
               
trainset = Data(root_dir = "....",annotation = annotation)
dataloader = DataLoader(trainset, batch_size=5,
                        shuffle=True, num_workers=4)


dataiter = iter(dataloader)


Now the iterable dataiter is created.
However, whenever I do : image,annotation = dataiter.next() , the code just keeps on running , never giving a result .
Can someone please explain this ?
Thanks .