快捷方式

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

大規模名人面部屬性 (CelebA) 資料集 資料集。

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

  • split (string) – {‘train’, ‘valid’, ‘test’, ‘all’} 之一。據此選擇資料集。

  • target_type (stringlist, 可選) –

    要使用的目標型別,attridentitybboxlandmarks。也可以是列表,以輸出包含所有指定目標型別的元組。目標代表

    • 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, 可選) – 一個函式/變換,接受 PIL 影像並返回變換後的版本。例如,transforms.PILToTensor

  • target_transform (callable, 可選) – 一個函式/變換,接受目標並對其進行變換。

  • download (bool, 可選) –

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

    警告

    下載資料集需要 gdown

特殊成員:

__getitem__(index: int) Tuple[Any, Any][原始碼]
引數:

index (int) – 索引

返回:

樣本和元資料,可選地由相應的變換進行變換。

返回型別:

(Any)

文件

查閱 PyTorch 的全面開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深入教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源