Skip to content

WARNING

该页面尚未翻译。 以下内容为英文原版。

tensorplay.vision.datasets.folder

Classes

class DatasetFolder [source]

python
DatasetFolder(root, loader, extensions=None, transform=None, target_transform=None, is_valid_file=None)

Bases: VisionDataset

Methods

__init__(self, root, loader, extensions=None, transform=None, target_transform=None, is_valid_file=None) [source]

Initialize self. See help(type(self)) for accurate signature.


extra_repr(self) -> str [source]


class ImageFolder [source]

python
ImageFolder(root, transform=None, target_transform=None, loader=<function default_loader at 0x0000021B12D3DA80>, is_valid_file=None)

Bases: DatasetFolder

A generic data loader where the images are arranged in this way:

python
root/dog/xxx.png
root/dog/xxy.png
root/dog/xxz.png

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

Args

  • root (string): Root directory path.
  • transform (callable, optional): A function/transform that takes in an PIL image and returns a transformed version. E.g, transforms.RandomCrop
  • target_transform (callable, optional): A function/transform that takes in the target and transforms it.
  • loader (callable, optional): A function to load an image given its path.
  • is_valid_file (callable, optional): A function that takes path of an Image file and check if the file is a valid_file (used to check of corrupt files)
Methods

__init__(self, root, transform=None, target_transform=None, loader=<function default_loader at 0x0000021B12D3DA80>, is_valid_file=None) [source]

Initialize self. See help(type(self)) for accurate signature.


extra_repr(self) -> str [source]


Functions

default_loader() [source]

python
default_loader(path)

make_dataset() [source]

python
make_dataset(directory: str, class_to_idx: Dict[str, int], extensions: Optional[Iterable[str]] = None, is_valid_file: Optional[Callable[[str], bool]] = None) -> List[Tuple[str, int]]

Generates a list of samples in the form (path_to_sample, class_index).

Args

  • directory (str): root directory path
  • class_to_idx (Dict[str, int]): A mapping from class name to class index.
  • extensions (Optional[Iterable[str]]): A list of allowed extensions (case-insensitive).
  • is_valid_file (Optional[Callable[[str], bool]]): A function that takes a file path and returns True if the file is valid.

Returns

List[Tuple[str, int]]: includes (path_to_sample, class_index) for valid samples.

基于 Apache 2.0 许可发布。

📚DeepWiki