Table of Contents
Shortcuts

# INaturalist

class torchvision.datasets.INaturalist(root: str, version: str = '2021_train', target_type: Union[List[str], str] = 'full', transform: Optional[Callable] = None, target_transform: Optional[Callable] = None, download: bool = False)

  iNaturalist Dataset.

  Parameters:

    - root (string) – Root directory of dataset where the image files are stored. This class does not require/use annotation files.

    - version (string, optional) – Which version of the dataset to download/use. One of ‘2017’, ‘2018’, ‘2019’, ‘2021_train’, ‘2021_train_mini’, ‘2021_valid’. Default: 2021_train.

    - target_type (string or list, optional) –

      Type of target to use, for 2021 versions, one of:

      - `full`: the full category (species)

      - `kingdom`: e.g. “Animalia”

      - `phylum`: e.g. “Arthropoda”

      - `class`: e.g. “Insecta”

      - `order`: e.g. “Coleoptera”

      - `family`: e.g. “Cleridae”

      - `genus`: e.g. “Trichodes”

      for 2017-2019 versions, one of:

      - `full`: the full (numeric) category

      - `super`: the super category, e.g. “Amphibians”

      Can also be a list to output a tuple with all specified target types. Defaults to `full`.

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

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

  __getitem__(index: int) → Tuple[Any, Any]
    Parameters:

      index (int) – Index

    Returns:

      (image, target) where the type of target specified by target_type.

    Return type:

      tuple

  category_name(category_type: str, category_id: int) → str
    Parameters:

      - category_type (str) – one of “full”, “kingdom”, “phylum”, “class”, “order”, “family”, “genus” or “super”

      - category_id (int) – an index (class id) from this category

    Returns:

      the name of the category

## 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

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.