feat: script
Browse files
cut-2d-masks-presentation-attack-detection.py
CHANGED
@@ -3,7 +3,7 @@ import pandas as pd
|
|
3 |
|
4 |
_CITATION = """\
|
5 |
@InProceedings{huggingface:dataset,
|
6 |
-
title = {2d-masks-presentation-attack-detection},
|
7 |
author = {TrainingDataPro},
|
8 |
year = {2023}
|
9 |
}
|
@@ -16,7 +16,7 @@ Videos are filmed in different lightning conditions and in different places
|
|
16 |
(indoors, outdoors). Each video in the dataset has an approximate duration of 2
|
17 |
seconds.
|
18 |
"""
|
19 |
-
_NAME = '2d-masks-presentation-attack-detection'
|
20 |
|
21 |
_HOMEPAGE = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}"
|
22 |
|
@@ -25,26 +25,15 @@ _LICENSE = ""
|
|
25 |
_DATA = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}/resolve/main/data/"
|
26 |
|
27 |
|
28 |
-
class
|
29 |
"""Small sample of image-text pairs"""
|
30 |
|
31 |
def _info(self):
|
32 |
return datasets.DatasetInfo(
|
33 |
description=_DESCRIPTION,
|
34 |
features=datasets.Features({
|
35 |
-
'
|
36 |
-
'
|
37 |
-
'real_2': datasets.Value('string'),
|
38 |
-
'real_3': datasets.Value('string'),
|
39 |
-
'real_4': datasets.Value('string'),
|
40 |
-
'mask_1': datasets.Value('string'),
|
41 |
-
'mask_2': datasets.Value('string'),
|
42 |
-
'mask_3': datasets.Value('string'),
|
43 |
-
'mask_4': datasets.Value('string'),
|
44 |
-
'cut_1': datasets.Value('string'),
|
45 |
-
'cut_2': datasets.Value('string'),
|
46 |
-
'cut_3': datasets.Value('string'),
|
47 |
-
'cut_4': datasets.Value('string')
|
48 |
}),
|
49 |
supervised_keys=None,
|
50 |
homepage=_HOMEPAGE,
|
@@ -52,60 +41,25 @@ class MasksPresentationAttackDetection(datasets.GeneratorBasedBuilder):
|
|
52 |
)
|
53 |
|
54 |
def _split_generators(self, dl_manager):
|
55 |
-
|
56 |
annotations = dl_manager.download(f"{_DATA}{_NAME}.csv")
|
57 |
-
|
58 |
return [
|
59 |
datasets.SplitGenerator(name=datasets.Split.TRAIN,
|
60 |
gen_kwargs={
|
61 |
-
"
|
62 |
'annotations': annotations
|
63 |
}),
|
64 |
]
|
65 |
|
66 |
-
def _generate_examples(self,
|
67 |
annotations_df = pd.read_csv(annotations, sep=';')
|
68 |
|
69 |
-
for idx, (
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
'
|
76 |
-
|
77 |
-
['real_1'].values[0],
|
78 |
-
'real_2':
|
79 |
-
annotations_df.loc[annotations_df['user'] == user]
|
80 |
-
['real_2'].values[0],
|
81 |
-
'real_3':
|
82 |
-
annotations_df.loc[annotations_df['user'] == user]
|
83 |
-
['real_3'].values[0],
|
84 |
-
'real_4':
|
85 |
-
annotations_df.loc[annotations_df['user'] == user]
|
86 |
-
['real_4'].values[0],
|
87 |
-
'mask_1':
|
88 |
-
annotations_df.loc[annotations_df['user'] == user]
|
89 |
-
['mask_1'].values[0],
|
90 |
-
'mask_2':
|
91 |
-
annotations_df.loc[annotations_df['user'] == user]
|
92 |
-
['mask_2'].values[0],
|
93 |
-
'mask_3':
|
94 |
-
annotations_df.loc[annotations_df['user'] == user]
|
95 |
-
['mask_3'].values[0],
|
96 |
-
'mask_4':
|
97 |
-
annotations_df.loc[annotations_df['user'] == user]
|
98 |
-
['mask_4'].values[0],
|
99 |
-
'cut_1':
|
100 |
-
annotations_df.loc[annotations_df['user'] == user]
|
101 |
-
['cut_1'].values[0],
|
102 |
-
'cut_2':
|
103 |
-
annotations_df.loc[annotations_df['user'] == user]
|
104 |
-
['cut_2'].values[0],
|
105 |
-
'cut_3':
|
106 |
-
annotations_df.loc[annotations_df['user'] == user]
|
107 |
-
['cut_3'].values[0],
|
108 |
-
'cut_4':
|
109 |
-
annotations_df.loc[annotations_df['user'] == user]
|
110 |
-
['cut_4'].values[0],
|
111 |
-
}
|
|
|
3 |
|
4 |
_CITATION = """\
|
5 |
@InProceedings{huggingface:dataset,
|
6 |
+
title = {cut-2d-masks-presentation-attack-detection},
|
7 |
author = {TrainingDataPro},
|
8 |
year = {2023}
|
9 |
}
|
|
|
16 |
(indoors, outdoors). Each video in the dataset has an approximate duration of 2
|
17 |
seconds.
|
18 |
"""
|
19 |
+
_NAME = 'cut-2d-masks-presentation-attack-detection'
|
20 |
|
21 |
_HOMEPAGE = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}"
|
22 |
|
|
|
25 |
_DATA = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}/resolve/main/data/"
|
26 |
|
27 |
|
28 |
+
class Cut2dMasksPresentationAttackDetection(datasets.GeneratorBasedBuilder):
|
29 |
"""Small sample of image-text pairs"""
|
30 |
|
31 |
def _info(self):
|
32 |
return datasets.DatasetInfo(
|
33 |
description=_DESCRIPTION,
|
34 |
features=datasets.Features({
|
35 |
+
'link': datasets.Value('string'),
|
36 |
+
'type': datasets.Value('string')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
}),
|
38 |
supervised_keys=None,
|
39 |
homepage=_HOMEPAGE,
|
|
|
41 |
)
|
42 |
|
43 |
def _split_generators(self, dl_manager):
|
44 |
+
masks = dl_manager.download(f"{_DATA}masks.tar.gz")
|
45 |
annotations = dl_manager.download(f"{_DATA}{_NAME}.csv")
|
46 |
+
masks = dl_manager.iter_archive(masks)
|
47 |
return [
|
48 |
datasets.SplitGenerator(name=datasets.Split.TRAIN,
|
49 |
gen_kwargs={
|
50 |
+
"masks": masks,
|
51 |
'annotations': annotations
|
52 |
}),
|
53 |
]
|
54 |
|
55 |
+
def _generate_examples(self, masks, annotations):
|
56 |
annotations_df = pd.read_csv(annotations, sep=';')
|
57 |
|
58 |
+
for idx, (mask_path, mask) in enumerate(masks):
|
59 |
+
yield idx, {
|
60 |
+
'link':
|
61 |
+
mask_path,
|
62 |
+
'type':
|
63 |
+
annotations_df.loc[annotations_df['link'] == mask_path]
|
64 |
+
['type'].values[0]
|
65 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|