frarch.datasets.caltech101 module
frarch.datasets.caltech101 module#
- class frarch.datasets.caltech101.Caltech101(subset: str = 'train', transform: Optional[Callable] = None, target_transform: Optional[Callable] = None, root: Union[str, pathlib.Path] = './data/')[source]#
Bases:
torch.utils.data.dataset.Dataset
Caltech 101 dataset object.
Data loader for the Caltech 101 dataset for object classification. The dataset can be obtained from https://data.caltech.edu/records/20086. The dataset is expected to have the following structure:
Expected dataset structure:
<root_folder> ├── class1 │ ├── image_xxxx.jpg . . . . . . . └── image_yyyy.jpg └── classN ├── image_xxxx.jpg . . . └── image_yyyy.jpg
- Parameters
subset (str) – “train” or “valid”. Subset to load. Defaults to “train”.
transform (Callable) – a callable object that takes an PIL.Image object and returns a modified PIL.Image object. Defaults to None, which won’t apply any transformation.
target_transform (Callable) – a callable object that the label data and returns modified label data. Defaults to None, which won’t apply any transformation.
root (Union[str, Path]) – root directory for the dataset. Defaults to ./data/.
References
Examples
Simple usage of the dataset class:
from frarch.datasets import Caltech101 from frarch.utils.data import create_dataloader from torchvision.transforms import ToTensor dataset = Caltech101("train", ToTensor, None, "./data/") dataloader = create_dataloader(dataset) for batch_idx, (batch, labels) in enumerate(dataloader): # process batch