image_folder_dataset: Create an image folder dataset

Description Usage Arguments Details

Description

A generic data loader for images stored in folders. See Details for more information.

Usage

1
2
3
4
5
6
7
image_folder_dataset(
  root,
  transform = NULL,
  target_transform = NULL,
  loader = NULL,
  is_valid_file = NULL
)

Arguments

root

Root directory path.

transform

A function/transform that takes in an PIL image and returns a transformed version. E.g, transform_random_crop().

target_transform

A function/transform that takes in the target and transforms it.

loader

A function to load an image given its path.

is_valid_file

A function that takes path of an Image file and check if the file is a valid file (used to check of corrupt files)

Details

This function assumes that the images for each class are contained in subdirectories of root. The names of these subdirectories are stored in the classes attribute of the returned object.

An example folder structure might look as follows:

1
2
3
4
5
6
7
root/dog/xxx.png
root/dog/xxy.png
root/dog/xxz.png

root/cat/123.png
root/cat/nsdf3.png
root/cat/asd932_.png

torchvision documentation built on Aug. 17, 2021, 5:06 p.m.