|
import datasets |
|
import pandas as pd |
|
|
|
_CITATION = """\ |
|
@InProceedings{huggingface:dataset, |
|
title = {hand-gesture-recognition-dataset}, |
|
author = {TrainingDataPro}, |
|
year = {2023} |
|
} |
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
The dataset consists of videos showcasing individuals demonstrating 5 different |
|
hand gestures (*"one", "four", "small", "fist", and "me"*). Each video captures |
|
a person prominently displaying a single hand gesture, allowing for accurate |
|
identification and differentiation of the gestures. |
|
The dataset offers a diverse range of individuals performing the gestures, |
|
enabling the exploration of variations in hand shapes, sizes, and movements |
|
across different individuals. |
|
The videos in the dataset are recorded in reasonable lighting conditions and |
|
with adequate resolution, to ensure that the hand gestures can be easily |
|
observed and studied. |
|
""" |
|
_NAME = 'hand-gesture-recognition-dataset' |
|
|
|
_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 HandGestureRecognitionDataset(datasets.GeneratorBasedBuilder): |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo(description=_DESCRIPTION, |
|
features=datasets.Features({ |
|
'set_id': datasets.Value('int32'), |
|
'fist': datasets.Value('string'), |
|
'four': datasets.Value('string'), |
|
'me': datasets.Value('string'), |
|
'one': datasets.Value('string'), |
|
'small': datasets.Value('string') |
|
}), |
|
supervised_keys=None, |
|
homepage=_HOMEPAGE, |
|
citation=_CITATION, |
|
license=_LICENSE) |
|
|
|
def _split_generators(self, dl_manager): |
|
files = dl_manager.download_and_extract(f"{_DATA}files.zip") |
|
annotations = dl_manager.download(f"{_DATA}{_NAME}.csv") |
|
files = dl_manager.iter_files(files) |
|
return [ |
|
datasets.SplitGenerator(name=datasets.Split.TRAIN, |
|
gen_kwargs={ |
|
"files": files, |
|
'annotations': annotations |
|
}), |
|
] |
|
|
|
def _generate_examples(self, files, annotations): |
|
annotations_df = pd.read_csv(annotations, sep=',') |
|
|
|
for idx, file_path in enumerate(files): |
|
set_id = int(file_path.split('/')[-2]) |
|
file_name = file_path.split('/')[-1] |
|
|
|
print(set_id, file_name) |
|
if 'fist' in file_name: |
|
data = { |
|
'set_id': |
|
set_id, |
|
'fist': |
|
annotations_df.loc[annotations_df['set_id'] == set_id] |
|
['fist'].values[0], |
|
'four': |
|
annotations_df.loc[annotations_df['set_id'] == set_id] |
|
['four'].values[0], |
|
'me': |
|
annotations_df.loc[annotations_df['set_id'] == set_id] |
|
['me'].values[0], |
|
'one': |
|
annotations_df.loc[annotations_df['set_id'] == set_id] |
|
['one'].values[0], |
|
'small': |
|
annotations_df.loc[annotations_df['set_id'] == set_id] |
|
['small'].values[0] |
|
} |
|
|
|
yield idx, data |
|
|