Shortcuts

CelebA

class torchvision.datasets.CelebA(root: str, 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 (string) – 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, or landmarks. Can also be a list to output a tuple with all specified target types. The targets represent:

    • attr (np.array shape=(40,) dtype=int): binary (0, 1) labels for attributes

    • identity (int): label for each person (data points with the same identity are the same person)

    • bbox (np.array shape=(4,) dtype=int): bounding box (x, y, width, height)

    • landmarks (np.array 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 to attr. If empty, None will be returned as target.

  • transform (callable, optional) – A function/transform that takes in an PIL image and returns a transformed version. E.g, transforms.ToTensor

  • 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.

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)

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources