| from xml.etree import ElementTree as ET |
|
|
| import datasets |
|
|
| _CITATION = """\ |
| @InProceedings{huggingface:dataset, |
| title = {silicone-masks-biometric-attacks}, |
| author = {TrainingDataPro}, |
| year = {2023} |
| } |
| """ |
|
|
| _DESCRIPTION = """\ |
| The dataset consists of videos of individuals and attacks with printed 2D masks and |
| silicone masks . Videos are filmed in different lightning conditions (*in a dark room, |
| daylight, light room and nightlight*). Dataset includes videos of people with different |
| attributes (*glasses, mask, hat, hood, wigs and mustaches for men*). |
| """ |
|
|
| _NAME = "silicone-masks-biometric-attacks" |
|
|
| _HOMEPAGE = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}" |
|
|
| _LICENSE = "" |
|
|
| _DATA = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}/resolve/main/data/" |
|
|
| _LABELS = ["real", "silicone", "mask"] |
|
|
|
|
| class SiliconeMasksBiometricAttacks(datasets.GeneratorBasedBuilder): |
| def _info(self): |
| return datasets.DatasetInfo( |
| description=_DESCRIPTION, |
| features=datasets.Features( |
| { |
| "id": datasets.Value("int32"), |
| "video_name": datasets.Value("string"), |
| "video_path": datasets.Value("string"), |
| "label": datasets.ClassLabel( |
| num_classes=len(_LABELS), |
| names=_LABELS, |
| ), |
| } |
| ), |
| supervised_keys=None, |
| homepage=_HOMEPAGE, |
| citation=_CITATION, |
| ) |
|
|
| def _split_generators(self, dl_manager): |
| videos = dl_manager.download(f"{_DATA}videos.tar.gz") |
| videos = dl_manager.iter_archive(videos) |
| return [ |
| datasets.SplitGenerator( |
| name=datasets.Split.TRAIN, |
| gen_kwargs={ |
| "videos": videos, |
| }, |
| ), |
| ] |
|
|
| def _generate_examples(self, videos): |
| for idx, ((video_path, video)) in enumerate(videos): |
| for lbl in _LABELS: |
| if lbl in video_path: |
| label = lbl |
|
|
| yield idx, { |
| "id": idx, |
| "video_name": video_path.split("/")[-1], |
| "video_path": video_path, |
| "label": label, |
| } |
|
|