Datasets:
feat: upload script
Browse files- printed_photos_attacks.py +32 -40
printed_photos_attacks.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 1 |
import datasets
|
| 2 |
-
import pandas as pd
|
| 3 |
|
| 4 |
_CITATION = """\
|
| 5 |
@InProceedings{huggingface:dataset,
|
| 6 |
-
title = {
|
| 7 |
author = {TrainingDataPro},
|
| 8 |
year = {2023}
|
| 9 |
}
|
|
@@ -14,7 +13,7 @@ The dataset consists of 40,000 videos and selfies with unique people. 15,000
|
|
| 14 |
attack replays from 4,000 unique devices. 10,000 attacks with A4 printouts and
|
| 15 |
10,000 attacks with cut-out printouts.
|
| 16 |
"""
|
| 17 |
-
_NAME = '
|
| 18 |
|
| 19 |
_HOMEPAGE = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}"
|
| 20 |
|
|
@@ -23,53 +22,46 @@ _LICENSE = "cc-by-nc-nd-4.0"
|
|
| 23 |
_DATA = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}/resolve/main/data/"
|
| 24 |
|
| 25 |
|
| 26 |
-
class
|
| 27 |
|
| 28 |
def _info(self):
|
| 29 |
-
return datasets.DatasetInfo(
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
homepage=_HOMEPAGE,
|
| 40 |
-
citation=_CITATION,
|
| 41 |
-
license=_LICENSE)
|
| 42 |
|
| 43 |
def _split_generators(self, dl_manager):
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
| 47 |
return [
|
| 48 |
datasets.SplitGenerator(name=datasets.Split.TRAIN,
|
| 49 |
gen_kwargs={
|
| 50 |
-
|
| 51 |
-
|
|
|
|
| 52 |
}),
|
| 53 |
]
|
| 54 |
|
| 55 |
-
def _generate_examples(self,
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
|
| 60 |
yield idx, {
|
| 61 |
-
'
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
'video_file':
|
| 68 |
-
video_path,
|
| 69 |
-
'phone_video_playback':
|
| 70 |
-
annotations_df.loc[annotations_df['link'] == file_name]
|
| 71 |
-
['phone_video_playback'].values[0],
|
| 72 |
-
'worker_id':
|
| 73 |
-
annotations_df.loc[annotations_df['link'] == file_name]
|
| 74 |
-
['worker_id'].values[0]
|
| 75 |
}
|
|
|
|
| 1 |
import datasets
|
|
|
|
| 2 |
|
| 3 |
_CITATION = """\
|
| 4 |
@InProceedings{huggingface:dataset,
|
| 5 |
+
title = {printed_photos_attacks},
|
| 6 |
author = {TrainingDataPro},
|
| 7 |
year = {2023}
|
| 8 |
}
|
|
|
|
| 13 |
attack replays from 4,000 unique devices. 10,000 attacks with A4 printouts and
|
| 14 |
10,000 attacks with cut-out printouts.
|
| 15 |
"""
|
| 16 |
+
_NAME = 'printed_photos_attacks'
|
| 17 |
|
| 18 |
_HOMEPAGE = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}"
|
| 19 |
|
|
|
|
| 22 |
_DATA = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}/resolve/main/data/"
|
| 23 |
|
| 24 |
|
| 25 |
+
class PrintedPhotosAttacks(datasets.GeneratorBasedBuilder):
|
| 26 |
|
| 27 |
def _info(self):
|
| 28 |
+
return datasets.DatasetInfo(description=_DESCRIPTION,
|
| 29 |
+
features=datasets.Features({
|
| 30 |
+
'attack': datasets.Value('string'),
|
| 31 |
+
'live_selfie': datasets.Image(),
|
| 32 |
+
'live_video': datasets.Value('string')
|
| 33 |
+
}),
|
| 34 |
+
supervised_keys=None,
|
| 35 |
+
homepage=_HOMEPAGE,
|
| 36 |
+
citation=_CITATION,
|
| 37 |
+
license=_LICENSE)
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
def _split_generators(self, dl_manager):
|
| 40 |
+
attacks = dl_manager.download(f"{_DATA}attack.tar.gz")
|
| 41 |
+
live_selfies = dl_manager.download(f"{_DATA}live_selfie.tar.gz")
|
| 42 |
+
live_videos = dl_manager.download(f"{_DATA}live_video.tar.gz")
|
| 43 |
+
attacks = dl_manager.iter_archive(attacks)
|
| 44 |
+
live_selfies = dl_manager.iter_archive(live_selfies)
|
| 45 |
+
live_videos = dl_manager.iter_archive(live_videos)
|
| 46 |
return [
|
| 47 |
datasets.SplitGenerator(name=datasets.Split.TRAIN,
|
| 48 |
gen_kwargs={
|
| 49 |
+
'attacks': attacks,
|
| 50 |
+
"live_selfies": live_selfies,
|
| 51 |
+
'live_videos': live_videos
|
| 52 |
}),
|
| 53 |
]
|
| 54 |
|
| 55 |
+
def _generate_examples(self, attacks, live_selfies, live_videos):
|
| 56 |
+
for idx, ((attack_path, attack), (live_selfie_path, live_selfie),
|
| 57 |
+
(live_video_path, live_video)) in enumerate(
|
| 58 |
+
zip(attacks, live_selfies, live_videos)):
|
| 59 |
|
| 60 |
yield idx, {
|
| 61 |
+
'attack': attack_path,
|
| 62 |
+
'live_selfie': {
|
| 63 |
+
'path': live_selfie_path,
|
| 64 |
+
'bytes': live_selfie
|
| 65 |
+
},
|
| 66 |
+
'live_video': live_video_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
}
|