File size: 2,640 Bytes
775876e
 
 
 
770f298
775876e
 
 
 
 
 
 
 
 
 
770f298
775876e
 
 
 
 
 
 
 
770f298
775876e
 
770f298
 
 
 
 
 
 
 
 
 
775876e
 
770f298
 
 
 
 
 
775876e
 
 
770f298
 
 
775876e
 
 
770f298
 
 
 
775876e
 
770f298
 
 
f3e3946
770f298
 
775876e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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
            }