Shortcuts

CocoDetection

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

MS Coco Detection 数据集。

它需要安装COCO API

Parameters:
  • root (str 或 pathlib.Path) – 图像下载到的根目录。

  • annFile (string) – JSON注释文件的路径。

  • transform (callable, optional) – 一个函数/变换,接收一个PIL图像并返回一个变换后的版本。例如,transforms.PILToTensor

  • target_transform (callable, optional) – 一个函数/转换,它接收目标并对其进行转换。

  • transforms (callable, optional) – 一个函数/转换,它接收输入样本及其目标作为输入,并返回转换后的版本。

使用 CocoDetection 的示例:

开始使用 transforms v2

Getting started with transforms v2

Transforms v2: 端到端目标检测/分割示例

Transforms v2: End-to-end object detection/segmentation example
Special-members:

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

index (int) – 索引

Returns:

样本和元数据,可选择通过各自的转换进行转换。

Return type:

(任何)