feat: add load script
Browse files
silicone-masks-biometric-attacks.py
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from xml.etree import ElementTree as ET
|
2 |
+
|
3 |
+
import datasets
|
4 |
+
|
5 |
+
_CITATION = """\
|
6 |
+
@InProceedings{huggingface:dataset,
|
7 |
+
title = {silicone-masks-biometric-attacks},
|
8 |
+
author = {TrainingDataPro},
|
9 |
+
year = {2023}
|
10 |
+
}
|
11 |
+
"""
|
12 |
+
|
13 |
+
_DESCRIPTION = """\
|
14 |
+
The dataset consists of videos of individuals and attacks with printed 2D masks and
|
15 |
+
silicone masks . Videos are filmed in different lightning conditions (*in a dark room,
|
16 |
+
daylight, light room and nightlight*). Dataset includes videos of people with different
|
17 |
+
attributes (*glasses, mask, hat, hood, wigs and mustaches for men*).
|
18 |
+
"""
|
19 |
+
|
20 |
+
_NAME = "silicone-masks-biometric-attacks"
|
21 |
+
|
22 |
+
_HOMEPAGE = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}"
|
23 |
+
|
24 |
+
_LICENSE = ""
|
25 |
+
|
26 |
+
_DATA = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}/resolve/main/data/"
|
27 |
+
|
28 |
+
_LABELS = ["real", "silicone", "mask"]
|
29 |
+
|
30 |
+
|
31 |
+
class SiliconeMasksBiometricAttacks(datasets.GeneratorBasedBuilder):
|
32 |
+
def _info(self):
|
33 |
+
return datasets.DatasetInfo(
|
34 |
+
description=_DESCRIPTION,
|
35 |
+
features=datasets.Features(
|
36 |
+
{
|
37 |
+
"id": datasets.Value("int32"),
|
38 |
+
"name": datasets.Value("string"),
|
39 |
+
"video": datasets.Value("string"),
|
40 |
+
"label": datasets.ClassLabel(
|
41 |
+
num_classes=len(_LABELS),
|
42 |
+
names=_LABELS,
|
43 |
+
),
|
44 |
+
}
|
45 |
+
),
|
46 |
+
supervised_keys=None,
|
47 |
+
homepage=_HOMEPAGE,
|
48 |
+
citation=_CITATION,
|
49 |
+
)
|
50 |
+
|
51 |
+
def _split_generators(self, dl_manager):
|
52 |
+
videos = dl_manager.download(f"{_DATA}videos.tar.gz")
|
53 |
+
videos = dl_manager.iter_archive(videos)
|
54 |
+
return [
|
55 |
+
datasets.SplitGenerator(
|
56 |
+
name=datasets.Split.TRAIN,
|
57 |
+
gen_kwargs={
|
58 |
+
"videos": videos,
|
59 |
+
},
|
60 |
+
),
|
61 |
+
]
|
62 |
+
|
63 |
+
def _generate_examples(self, videos):
|
64 |
+
for idx, ((video_path, video)) in enumerate(videos):
|
65 |
+
for lbl in _LABELS:
|
66 |
+
if lbl in video_path:
|
67 |
+
label = lbl
|
68 |
+
|
69 |
+
yield idx, {
|
70 |
+
"id": idx,
|
71 |
+
"name": video_path.split("/")[-1],
|
72 |
+
"video": video_path,
|
73 |
+
"label": label,
|
74 |
+
}
|