CelebA — Torchvision 0.22 documentation (original) (raw)
class torchvision.datasets.CelebA(root: Union[str, Path], split: str = 'train', target_type: Union[List[str], str] = 'attr', transform: Optional[Callable] = None, target_transform: Optional[Callable] = None, download: bool = False)[source]¶
Large-scale CelebFaces Attributes (CelebA) Dataset Dataset.
Parameters:
- root (str or
pathlib.Path
) – Root directory where images are downloaded to. - split (string) – One of {‘train’, ‘valid’, ‘test’, ‘all’}. Accordingly dataset is selected.
- target_type (string or list, optional) –
Type of target to use,attr
,identity
,bbox
, orlandmarks
. Can also be a list to output a tuple with all specified target types. The targets represent:attr
(Tensor shape=(40,) dtype=int): binary (0, 1) labels for attributesidentity
(int): label for each person (data points with the same identity are the same person)bbox
(Tensor shape=(4,) dtype=int): bounding box (x, y, width, height)landmarks
(Tensor shape=(10,) dtype=int): landmark points (lefteye_x, lefteye_y, righteye_x, righteye_y, nose_x, nose_y, leftmouth_x, leftmouth_y, rightmouth_x, rightmouth_y)
Defaults toattr
. If empty,None
will be returned as target.
- transform (callable , optional) – A function/transform that takes in a PIL image and returns a transformed version. E.g,
transforms.PILToTensor
- target_transform (callable , optional) – A function/transform that takes in the target and transforms it.
- 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.
Warning
To download the dataset gdown is required.
Special-members:
__getitem__(index: int) → Tuple[Any, Any][source]¶
Parameters:
index (int) – Index
Returns:
Sample and meta data, optionally transformed by the respective transforms.
Return type:
(Any)