I have two dataset folder of tif images, one is a folder called BMMCdata, and the other one is the mask of BMMCdata images called BMMCmasks(the name of images are corresponds). I am trying to make a customised dataset and also split the data randomly to train and test. Thank you in advance. at the moment I am getting an error
AttributeError: 'CustomDataset' object has no attribute 'len'


import torch
from torch.utils.data.dataset import Dataset  # For custom data-sets
from torchvision import transforms
from PIL import Image
import glob

folder_data = "D:\\Neda\\Pytorch\\U-net\\BMMCdata\\data"


class CustomDataset(Dataset):
    def __init__(self, root):   # initial logic happens like transform

        self.filename = folder_data
        self.root = root
        self.to_tensor = transforms.ToTensor()

        image_list = []
        for filename in glob.glob('folder_data/*.tif'):
            im = Image.open(filename)
            image_list.append(im)
            print(filename)

    def __getitem__(self, index):
        image = Image.open(self.image_list[index])
        return self.to_tensor(image)

    def __len__(self):  # return count of sample we have

        return self.len


custom_img = CustomDataset(folder_data)
# total images in set
print(custom_img.len)

train_len = int(0.6*custom_img.len)
test_len = custom_img.len - train_len
train_set, test_set = CustomDataset.random_split(custom_img, lengths=[train_len, test_len])
# check lens of subset
len(train_set), len(test_set)

train_set = CustomDataset(folder_data)
train_set = torch.utils.data.TensorDataset(train_set, train=True, batch_size=4)
train_loader = torch.utils.data.DataLoader(train_set, batch_size=4, shuffle=True, num_workers=1)
print(train_set)
print(train_loader)

test_set = torch.utils.data.DataLoader(Dataset, batch_size=4, sampler=test_set)
test_loader = torch.utils.data.DataLoader(Dataset, batch_size=4)