|
import datasets |
|
import pandas as pd |
|
|
|
_CITATION = """\ |
|
@InProceedings{huggingface:dataset, |
|
title = {high_quality_webcam_video_attacks}, |
|
author = {TrainingDataPro}, |
|
year = {2023} |
|
} |
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
The dataset includes live-recorded Anti-Spoofing videos from around the world, |
|
captured via **high-quality** webcams with Full HD resolution and above. |
|
""" |
|
_NAME = 'high_quality_webcam_video_attacks' |
|
|
|
_HOMEPAGE = f"https://huggingface.co./datasets/TrainingDataPro/{_NAME}" |
|
|
|
_LICENSE = "cc-by-nc-nd-4.0" |
|
|
|
_DATA = f"https://huggingface.co./datasets/TrainingDataPro/{_NAME}/resolve/main/data/" |
|
|
|
|
|
class HighQualityWebcamVideoAttacks(datasets.GeneratorBasedBuilder): |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=datasets.Features({ |
|
'video_file': datasets.Value('string'), |
|
'assignment_id': datasets.Value('string'), |
|
'worker_id': datasets.Value('string'), |
|
'gender': datasets.Value('string'), |
|
'age': datasets.Value('uint8'), |
|
'country': datasets.Value('string'), |
|
'resolution': datasets.Value('string') |
|
}), |
|
supervised_keys=None, |
|
homepage=_HOMEPAGE, |
|
citation=_CITATION, |
|
license=_LICENSE) |
|
|
|
def _split_generators(self, dl_manager): |
|
videos = dl_manager.download(f"{_DATA}videos.tar.gz") |
|
annotations = dl_manager.download(f"{_DATA}{_NAME}.csv") |
|
videos = dl_manager.iter_archive(videos) |
|
return [ |
|
datasets.SplitGenerator(name=datasets.Split.TRAIN, |
|
gen_kwargs={ |
|
"videos": videos, |
|
'annotations': annotations |
|
}), |
|
] |
|
|
|
def _generate_examples(self, videos, annotations): |
|
annotations_df = pd.read_csv(annotations, sep=';') |
|
for idx, (image_path, video) in enumerate(videos): |
|
file_name = image_path.split('/')[-1] |
|
assignment_id = file_name.split('.')[0] |
|
|
|
yield idx, { |
|
"video_file": |
|
file_name, |
|
'assignment_id': |
|
assignment_id, |
|
'worker_id': |
|
annotations_df.loc[ |
|
annotations_df['assignment_id'] == assignment_id] |
|
['worker_id'].values[0], |
|
'gender': |
|
annotations_df.loc[ |
|
annotations_df['assignment_id'] == assignment_id] |
|
['gender'].values[0], |
|
'age': |
|
annotations_df.loc[ |
|
annotations_df['assignment_id'] == assignment_id] |
|
['age'].values[0], |
|
'country': |
|
annotations_df.loc[ |
|
annotations_df['assignment_id'] == assignment_id] |
|
['country'].values[0], |
|
'resolution': |
|
annotations_df.loc[ |
|
annotations_df['assignment_id'] == assignment_id] |
|
['resolution'].values[0] |
|
} |
|
|