[docs]classGTSRB(VisionDataset):"""`German Traffic Sign Recognition Benchmark (GTSRB) <https://benchmark.ini.rub.de/>`_ Dataset. Args: root (string): Root directory of the dataset. split (string, optional): The dataset split, supports ``"train"`` (default), or ``"test"``. 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. """def__init__(self,root:str,split:str="train",transform:Optional[Callable]=None,target_transform:Optional[Callable]=None,download:bool=False,)->None:super().__init__(root,transform=transform,target_transform=target_transform)self._split=verify_str_arg(split,"split",("train","test"))self._base_folder=pathlib.Path(root)/"gtsrb"self._target_folder=(self._base_folder/"GTSRB"/("Training"ifself._split=="train"else"Final_Test/Images"))ifdownload:self.download()ifnotself._check_exists():raiseRuntimeError("Dataset not found. You can use download=True to download it")ifself._split=="train":samples=make_dataset(str(self._target_folder),extensions=(".ppm",))else:withopen(self._base_folder/"GT-final_test.csv")ascsv_file:samples=[(str(self._target_folder/row["Filename"]),int(row["ClassId"]))forrowincsv.DictReader(csv_file,delimiter=";",skipinitialspace=True)]self._samples=samplesself.transform=transformself.target_transform=target_transformdef__len__(self)->int:returnlen(self._samples)
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.