feat: upload script
Browse files
monitors-replay-attacks-dataset.py
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import datasets
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
_CITATION = """\
|
5 |
+
@InProceedings{huggingface:dataset,
|
6 |
+
title = {monitors-replay-attacks-dataset},
|
7 |
+
author = {TrainingDataPro},
|
8 |
+
year = {2023}
|
9 |
+
}
|
10 |
+
"""
|
11 |
+
|
12 |
+
_DESCRIPTION = """\
|
13 |
+
The dataset consists of videos of replay attacks played on different models of
|
14 |
+
computers. The dataset solves tasks in the field of anti-spoofing and it is
|
15 |
+
useful for buisness and safety systems.
|
16 |
+
The dataset includes: **replay attacks** - videos of real people played
|
17 |
+
on a computer and filmed on the phone.
|
18 |
+
"""
|
19 |
+
_NAME = 'monitors-replay-attacks-dataset'
|
20 |
+
|
21 |
+
_HOMEPAGE = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}"
|
22 |
+
|
23 |
+
_LICENSE = "cc-by-nc-nd-4.0"
|
24 |
+
|
25 |
+
_DATA = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}/resolve/main/data/"
|
26 |
+
|
27 |
+
|
28 |
+
class MonitorsReplayAttacksDataset(datasets.GeneratorBasedBuilder):
|
29 |
+
|
30 |
+
def _info(self):
|
31 |
+
return datasets.DatasetInfo(description=_DESCRIPTION,
|
32 |
+
features=datasets.Features({
|
33 |
+
'file': datasets.Value('string'),
|
34 |
+
'phone': datasets.Value('string'),
|
35 |
+
'computer': datasets.Value('string'),
|
36 |
+
'gender': datasets.Value('string'),
|
37 |
+
'age': datasets.Value('int16'),
|
38 |
+
'country': datasets.Value('string'),
|
39 |
+
}),
|
40 |
+
supervised_keys=None,
|
41 |
+
homepage=_HOMEPAGE,
|
42 |
+
citation=_CITATION,
|
43 |
+
license=_LICENSE)
|
44 |
+
|
45 |
+
def _split_generators(self, dl_manager):
|
46 |
+
attacks = dl_manager.download(f"{_DATA}attacks.tar.gz")
|
47 |
+
annotations = dl_manager.download(f"{_DATA}{_NAME}.csv")
|
48 |
+
attacks = dl_manager.iter_archive(attacks)
|
49 |
+
return [
|
50 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN,
|
51 |
+
gen_kwargs={
|
52 |
+
"attacks": attacks,
|
53 |
+
'annotations': annotations
|
54 |
+
}),
|
55 |
+
]
|
56 |
+
|
57 |
+
def _generate_examples(self, attacks, annotations):
|
58 |
+
annotations_df = pd.read_csv(annotations, sep=';')
|
59 |
+
|
60 |
+
for idx, (video_path, video) in enumerate(attacks):
|
61 |
+
yield idx, {
|
62 |
+
'file':
|
63 |
+
video_path,
|
64 |
+
'phone':
|
65 |
+
annotations_df.loc[annotations_df['file'].str.lower() ==
|
66 |
+
video_path.lower()]['phone'].values[0],
|
67 |
+
'computer':
|
68 |
+
annotations_df.loc[annotations_df['file'].str.lower() ==
|
69 |
+
video_path.lower()]
|
70 |
+
['computer'].values[0],
|
71 |
+
'gender':
|
72 |
+
annotations_df.loc[annotations_df['file'].str.lower() ==
|
73 |
+
video_path.lower()]['gender'].values[0],
|
74 |
+
'age':
|
75 |
+
annotations_df.loc[annotations_df['file'].str.lower() ==
|
76 |
+
video_path.lower()]['age'].values[0],
|
77 |
+
'country':
|
78 |
+
annotations_df.loc[annotations_df['file'].str.lower() ==
|
79 |
+
video_path.lower()]['country'].values[0]
|
80 |
+
}
|