[docs]classFER2013(VisionDataset):"""`FER2013 <https://www.kaggle.com/c/challenges-in-representation-learning-facial-expression-recognition-challenge>`_ Dataset. Args: root (string): Root directory of dataset where directory ``root/fer2013`` exists. 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. """_RESOURCES={"train":("train.csv","3f0dfb3d3fd99c811a1299cb947e3131"),"test":("test.csv","b02c2298636a634e8c2faabbf3ea9a23"),}def__init__(self,root:str,split:str="train",transform:Optional[Callable]=None,target_transform:Optional[Callable]=None,)->None:self._split=verify_str_arg(split,"split",self._RESOURCES.keys())super().__init__(root,transform=transform,target_transform=target_transform)base_folder=pathlib.Path(self.root)/"fer2013"file_name,md5=self._RESOURCES[self._split]data_file=base_folder/file_nameifnotcheck_integrity(str(data_file),md5=md5):raiseRuntimeError(f"{file_name} not found in {base_folder} or corrupted. "f"You can download it from "f"https://www.kaggle.com/c/challenges-in-representation-learning-facial-expression-recognition-challenge")withopen(data_file,"r",newline="")asfile:self._samples=[(torch.tensor([int(idx)foridxinrow["pixels"].split()],dtype=torch.uint8).reshape(48,48),int(row["emotion"])if"emotion"inrowelseNone,)forrowincsv.DictReader(file)]def__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.