I implemented a custom dataset class in PyTorch.
Currently I am reading the data likes this:
# paths
paths =  [x for x in glob.glob("polyp_db_sequences/*/*") if os.path.isdir(x)] #all paths that contain images

# splits
train_paths = random.sample(paths, int(len(paths) * 0.8)) #input for train dataset
test_paths = [x for x in paths if x not in train_paths] #input for test dataset

train_set = MyDataset(train_paths)
train_loader = DataLoader(train_set, batch_size = 16)

However, instead of the 80/20 splitting above, I’d like to use Kfold to split the data into train and test set but since I only have the paths, I don’t know how to do that.