frarch.datasets.oxford_pets module
frarch.datasets.oxford_pets module#
- class frarch.datasets.oxford_pets.OxfordPets(subset: str = 'train', transform: Optional[Callable] = None, target_transform: Optional[Callable] = None, download: bool = True, root: Union[str, pathlib.Path] = '~/.cache/frarch/datasets/oxford_pets/')[source]#
Bases:
torch.utils.data.dataset.Dataset
Oxford Pets dataset object.
Data loader for the Oxford Pets dataset for pet recognition. The dataset can be obtained from https://www.robots.ox.ac.uk/~vgg/data/pets/data/images.tar.gz and their corresponding labels in https://www.robots.ox.ac.uk/~vgg/data/pets/data/annotations.tar.gz.
- 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.
download (bool) – True for downloading and storing the dataset data in the root directory if it’s not present. Defaults to True.
root (Union[str, Path]) – root directory for the dataset. Defaults to ~/.cache/frarch/datasets/oxford_pets/.
References
Examples
Simple usage of the dataset class:
from frarch.datasets import Mit67 from frarch.utils.data import create_dataloader from torchvision.transforms import ToTensor dataset = OxfordPets( "train", ToTensor, None, True, "./data/") dataloader = create_dataloader(dataset) for batch_idx, (batch, labels) in enumerate(dataloader): # process batch