快捷方式

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)[原始碼]

Large-scale CelebFaces Attributes (CelebA) Dataset 資料集。

參數:
  • root (str 或 pathlib.Path) – 圖片下載後的根目錄。

  • split (string) – 從 {‘train’, ‘valid’, ‘test’, ‘all’} 中擇一。根據所選項目選擇資料集。

  • target_type (stringlist, optional) –

    要使用的目標類型, attr, identity, bbox, 或 landmarks。 也可以是一個列表,以輸出包含所有指定目標類型的元組。 這些目標代表

    • attr (Tensor shape=(40,) dtype=int): 屬性的二元 (0, 1) 標籤

    • identity (int): 每個人的標籤(具有相同身份的資料點是同一個人)

    • bbox (Tensor shape=(4,) dtype=int): 邊界框 (x, y, width, height)

    • landmarks (Tensor shape=(10,) dtype=int): 地標點 (lefteye_x, lefteye_y, righteye_x, righteye_y, nose_x, nose_y, leftmouth_x, leftmouth_y, rightmouth_x, rightmouth_y)

    預設為 attr。 如果為空,則將返回 None 作為目標。

  • transform (callable, optional) – 接收 PIL 圖像並返回轉換版本的函式/轉換。 例如, transforms.PILToTensor

  • target_transform (callable, optional) – 接收目標並轉換它的函式/轉換。

  • download (bool, optional) –

    如果為 true,則從網際網路下載資料集並將其放入根目錄。 如果已下載資料集,則不會再次下載。

    警告

    要下載資料集,需要 gdown

特殊成員:

__getitem__(index: int) Tuple[Any, Any][source]
參數:

index (int) – 索引

返回:

範例和元資料,可選擇透過各自的轉換進行轉換。

返回類型:

(Any)

文件

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