快捷方式

CelebA

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]

大规模 CelebFaces Attributes (CelebA) 数据集 数据集。

参数:
  • root (str 或 pathlib.Path) – 图像下载到的根目录。

  • split (字符串) – {‘train’, ‘valid’, ‘test’, ‘all’} 之一。据此选择数据集。

  • target_type (字符串列表, 可选) –

    要使用的目标类型,attridentitybboxlandmarks。也可以是一个列表,以输出包含所有指定目标类型的元组。目标表示

    • attr (Tensor shape=(40,) dtype=int): 属性的二进制 (0, 1) 标签

    • identity (int): 每个人的标签(具有相同身份的数据点是同一个人)

    • bbox (Tensor shape=(4,) dtype=int): 边界框 (x, y, 宽度, 高度)

    • landmarks (Tensor shape=(10,) dtype=int): 地标点(左眼_x、左眼_y、右眼_x、右眼_y、鼻子_x、鼻子_y、左嘴角_x、左嘴角_y、右嘴角_x、右嘴角_y)

    默认为 attr。如果为空,将返回 None 作为目标。

  • transform (可调用对象, 可选) – 接收 PIL 图像并返回转换版本的函数/转换。例如,transforms.PILToTensor

  • target_transform (可调用对象, 可选) – 接收目标并对其进行转换的函数/转换。

  • download (bool, 可选) –

    如果为 true,则从互联网下载数据集并将其放入根目录。如果数据集已下载,则不会再次下载。

    警告

    要下载数据集,需要 gdown

特殊成员:

__getitem__(index: int) Tuple[Any, Any][source]
参数:

index (int) – 索引

返回:

样本和元数据,可以选择通过各自的转换进行转换。

返回类型:

(Any)

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取面向初学者和高级开发者的深入教程

查看教程

资源

查找开发资源并获得您的问题解答

查看资源