快捷方式

iNaturalist

class torchvision.datasets.INaturalist(root: Union[str, Path], version: str = '2021_train', target_type: Union[list[str], str] = 'full', transform: Optional[Callable] = None, target_transform: Optional[Callable] = None, download: bool = False, loader: Optional[Callable[[Union[str, Path]]], Any]] = None)[原始碼]

iNaturalist 資料集。

引數:
  • root (str 或 pathlib.Path) – 儲存影像檔案的根目錄。此類不要求/使用註釋檔案。

  • version (string, optional) – 要下載/使用的資料集版本。可以是 '2017'、'2018'、'2019'、'2021_train'、'2021_train_mini'、'2021_valid' 之一。預設值:2021_train

  • target_type (stringlist, optional) –

    要使用的目標型別,對於 2021 版本,可以是以下之一:

    • full: 完整類別(物種)

    • kingdom: 例如,“Animalia”(動物界)

    • phylum: 例如,“Arthropoda”(節肢動物門)

    • class: 例如,“Insecta”(昆蟲綱)

    • order: 例如,“Coleoptera”(鞘翅目)

    • family: 例如,“Cleridae”( LikeLikeidae 屬)

    • genus: 例如,“Trichodes”

    對於 2017-2019 版本,可以是以下之一:

    • full: 完整(數字)類別

    • super: 超類別,例如“Amphibians”(兩棲動物)

    也可以是一個列表,輸出包含所有指定目標型別的元組。預設為 full

  • transform (callable, optional) – 一個函式/變換,接受 PIL 影像並返回變換後的版本。例如,transforms.RandomCrop

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

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

  • loader (callable, optional) – 一個載入給定路徑的影像的函式。預設情況下,它使用 PIL 作為影像載入器,但使用者也可以傳入 torchvision.io.decode_image 以直接將影像資料解碼為張量。

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

index (int) – 索引

返回:

(image, target),其中 target 的型別由 target_type 指定。

返回型別:

元組

category_name(category_type: str, category_id: int) str[原始碼]
引數:
  • category_type (str) – “full”、“kingdom”、“phylum”、“class”、“order”、“family”、“genus”或“super”之一

  • category_id (int) – 此類別的索引(類 ID)

返回:

該類別的名稱

文件

訪問全面的 PyTorch 開發者文件

檢視文件

教程

為初學者和高階開發者提供深入的教程

檢視教程

資源

查詢開發資源並讓您的問題得到解答

檢視資源