快捷方式

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 数据集包含 196 类汽车的 16,185 张图像。数据被分为 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) – 此参数是为了向后兼容而存在的,但它不会下载数据集,因为原始网址已不再可用。

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

特殊成员:

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

返回给定索引的 pil_image 和 class_id

文档

访问全面的 PyTorch 开发者文档

查看文档

教程

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

查看教程

资源

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

查看资源