import datasets _CITATION = """\ @InProceedings{huggingface:dataset, title = {printed_photos_attacks}, author = {TrainingDataPro}, year = {2023} } """ _DESCRIPTION = """\ The dataset consists of 40,000 videos and selfies with unique people. 15,000 attack replays from 4,000 unique devices. 10,000 attacks with A4 printouts and 10,000 attacks with cut-out printouts. """ _NAME = 'printed_photos_attacks' _HOMEPAGE = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}" _LICENSE = "cc-by-nc-nd-4.0" _DATA = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}/resolve/main/data/" class PrintedPhotosAttacks(datasets.GeneratorBasedBuilder): def _info(self): return datasets.DatasetInfo(description=_DESCRIPTION, features=datasets.Features({ 'attack': datasets.Value('string'), 'live_selfie': datasets.Image(), 'live_video': datasets.Value('string') }), supervised_keys=None, homepage=_HOMEPAGE, citation=_CITATION, license=_LICENSE) def _split_generators(self, dl_manager): attacks = dl_manager.download(f"{_DATA}attack.tar.gz") live_selfies = dl_manager.download(f"{_DATA}live_selfie.tar.gz") live_videos = dl_manager.download(f"{_DATA}live_video.tar.gz") attacks = dl_manager.iter_archive(attacks) live_selfies = dl_manager.iter_archive(live_selfies) live_videos = dl_manager.iter_archive(live_videos) return [ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={ 'attacks': attacks, "live_selfies": live_selfies, 'live_videos': live_videos }), ] def _generate_examples(self, attacks, live_selfies, live_videos): for idx, ((attack_path, attack), (live_selfie_path, live_selfie), (live_video_path, live_video)) in enumerate( zip(attacks, live_selfies, live_videos)): yield idx, { 'attack': attack_path, 'live_selfie': { 'path': live_selfie_path, 'bytes': live_selfie.read() }, 'live_video': live_video_path }