Cannot use Dataloader, Type error

Hello, I am getting this error “TypeError: ‘numpy.float64’ object cannot be interpreted as an integer” when trying to iterate through my DataLoader.

class MyFramesDataset(Dataset):
    def __init__(self, paths, labels, num_frames, transform=None):
        self.video_path = paths
        self.num_of_frames = num_frames
        self.labels = labels
        self.transform = transform

    def __len__(self):
    def __getitem__(self, index):
        Generates one sample of data.
        label = self.labels[index]
        num_frames = self.num_of_frames[index]  

        X = []
        # Read frames of video specified from video_path 
        for i in range(num_frames):
            image =, 'frame{:04d}.jpg'.format(i))).convert('RGB')
            if self.transform:
                image = self.transform(image)
        X = torch.stack(X, dim=0)
        y = torch.LongTensor(label)    
        return X, y  

transforms = transforms.Compose([
    transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),

batch_size = 16
train_frame_dataset = MyFramesDataset(train_paths, train_labels, train_num_frames, transforms)
train_dataloader = DataLoader(train_frame_dataset, batch_size, shuffle=False)
for batch_idx, (X, y) in enumerate(train_dataloader):

the error I am getting is:

The reason for this error is the type of “num_frames” variable. Its type is a float but “range” function wants integer. You need to convert the type of “num_frames” from float to int.