快捷方式

StanfordCars

class torchvision.datasets.StanfordCars(root: ~typing.Union[str, ~pathlib.Path], split: str = 'train', transform: ~typing.Optional[~typing.Callable] = None, target_transform: ~typing.Optional[~typing.Callable] = None, download: bool = False, loader: ~typing.Callable[[str], ~typing.Any] = <function default_loader>)[source]

Stanford Cars 数据集

Cars 数据集包含 16,185 张图像,涵盖 196 类汽车。数据被分为 8,144 张训练图像和 8,041 张测试图像,其中每个类别大致按 50-50 的比例划分。

原始网址为 https://ai.stanford.edu/~jkrause/cars/car_dataset.html,但该数据集已不再在线可用。

注意

此类需要 scipy 来从 .mat 格式加载目标文件。

参数:
  • root (str 或 pathlib.Path) – 数据集的根目录

  • split (string, optional) – 数据集划分,支持 "train" (默认) 或 "test"

  • transform (callable, optional) – 一个函数/转换,接收 PIL 图像或 torch.Tensor,具体取决于提供的加载器,并返回转换后的版本。例如,transforms.RandomCrop

  • target_transform (可调用对象, 可选) – 一个函数/变换,接受目标并对其进行变换。

  • download (bool, optional) – 此参数用于向后兼容,但它不会下载数据集,因为原始 URL 已不再可用。

  • loader (callable, optional) – 一个用于加载给定路径的图像的函数。默认情况下,它使用 PIL 作为图像加载器,但用户也可以传入 torchvision.io.decode_image 以直接将图像数据解码为张量。

特殊成员:

__getitem__(idx: int) tuple[Any, Any][source]

返回给定索引的 pil_image 和 class_id

文档

访问全面的 PyTorch 开发者文档

查看文档

教程

为初学者和高级开发者提供深入的教程

查看教程

资源

查找开发资源并让您的问题得到解答

查看资源