How to load datasets using torchvision.datasets.Imagefolder and divide into train and test?

dataset = datasets.ImageFolder(root='/data_path', transform=transform)

After the above code, how can I split the dataset into 20 percent for testing and 80 percent for training and load into torch.utils.data.DataLoader?

2 Likes

Here’s an example from somewhere else.

1 Like

what should be the root directory parameter in torchvision.datasets.ImageFolder on google colab

what should be the root= ‘data_path’ on google colab…?

perhaps the code changed but that link has no mention of ImageFolder

3 Likes