Table of Contents
Shortcuts

# CocoDetection

class torchvision.datasets.CocoDetection(root: str, annFile: str, transform: Optional[Callable] = None, target_transform: Optional[Callable] = None, transforms: Optional[Callable] = None)

  MS Coco Detection Dataset.

  It requires the COCO API to be installed.

  Parameters:

    - root (string) – Root directory where images are downloaded to.

    - annFile (string) – Path to json annotation file.

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

    - target_transform (callable, optional) – A function/transform that takes in the target and transforms it.

    - transforms (callable, optional) – A function/transform that takes input sample and its target as entry and returns a transformed version.

  Special-members:

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

      index (int) – Index

    Returns:

      Sample and meta data, optionally transformed by the respective transforms.

    Return type:

      (Any)

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