WARNING
该页面尚未翻译。 以下内容为英文原版。
tensorplay.vision.datasets
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_.pngArgs
- 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]
class MNIST [source]
python
MNIST(root=None, train=True, transform=None, target_transform=None, download=False)Bases: VisionDataset
MNIST <http://yann.lecun.com/exdb/mnist/>_ Dataset.
Args
- root (
string, optional): Root directory of dataset whereMNIST/processed/training.ptandMNIST/processed/test.ptexist. If None, uses default cache directory. - train (
bool, optional): If True, creates dataset fromtraining.pt, otherwise fromtest.pt. - download (
bool, optional): If true, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not downloaded again. - 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.
Methods
__init__(self, root=None, train=True, transform=None, target_transform=None, download=False) [source]
Initialize self. See help(type(self)) for accurate signature.
download(self) [source]
Download the MNIST data if it doesn't exist in processed_folder already.
extra_repr(self) -> str [source]
class VisionDataset [source]
python
VisionDataset(root, transform=None, target_transform=None)Bases: Dataset
Methods
__init__(self, root, transform=None, target_transform=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.
