Vadzim Kashko commited on
Commit
9d65543
1 Parent(s): d87df01

feat: script

Browse files
Files changed (1) hide show
  1. hand-gesture-recognition-dataset.py +84 -0
hand-gesture-recognition-dataset.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+ import pandas as pd
3
+
4
+ _CITATION = """\
5
+ @InProceedings{huggingface:dataset,
6
+ title = {hand-gesture-recognition-dataset},
7
+ author = {TrainingDataPro},
8
+ year = {2023}
9
+ }
10
+ """
11
+
12
+ _DESCRIPTION = """\
13
+ The dataset consists of videos showcasing individuals demonstrating 5 different
14
+ hand gestures (*"one", "four", "small", "fist", and "me"*). Each video captures
15
+ a person prominently displaying a single hand gesture, allowing for accurate
16
+ identification and differentiation of the gestures.
17
+ The dataset offers a diverse range of individuals performing the gestures,
18
+ enabling the exploration of variations in hand shapes, sizes, and movements
19
+ across different individuals.
20
+ The videos in the dataset are recorded in reasonable lighting conditions and
21
+ with adequate resolution, to ensure that the hand gestures can be easily
22
+ observed and studied.
23
+ """
24
+ _NAME = 'hand-gesture-recognition-dataset'
25
+
26
+ _HOMEPAGE = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}"
27
+
28
+ _LICENSE = "cc-by-nc-nd-4.0"
29
+
30
+ _DATA = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}/resolve/main/data/"
31
+
32
+
33
+ class HandGestureRecognitionDataset(datasets.GeneratorBasedBuilder):
34
+
35
+ def _info(self):
36
+ return datasets.DatasetInfo(description=_DESCRIPTION,
37
+ features=datasets.Features({
38
+ 'set_id': datasets.Value('int32'),
39
+ 'fist': datasets.Value('string'),
40
+ 'four': datasets.Value('string'),
41
+ 'me': datasets.Value('string'),
42
+ 'one': datasets.Value('string'),
43
+ "small": datasets.Value('string')
44
+ }),
45
+ supervised_keys=None,
46
+ homepage=_HOMEPAGE,
47
+ citation=_CITATION,
48
+ license=_LICENSE)
49
+
50
+ def _split_generators(self, dl_manager):
51
+ files = dl_manager.download_and_extract(f"{_DATA}files.zip")
52
+ annotations = dl_manager.download(f"{_DATA}{_NAME}.csv")
53
+ files = dl_manager.iter_files(files)
54
+ return [
55
+ datasets.SplitGenerator(name=datasets.Split.TRAIN,
56
+ gen_kwargs={
57
+ "files": files,
58
+ 'annotations': annotations
59
+ }),
60
+ ]
61
+
62
+ def _generate_examples(self, files, annotations):
63
+ annotations_df = pd.read_csv(annotations, sep=';')
64
+
65
+ files = sorted(files)
66
+ files = [files[i:i + 5] for i in range(0, len(files), 5)]
67
+
68
+ for idx, images_set in enumerate(files):
69
+ set_id = int(images_set[0].split('/')[2])
70
+ data = {'set_id': set_id}
71
+
72
+ for file in images_set:
73
+ if 'fist' in file.lower():
74
+ data['fist'] = file
75
+ elif 'four' in file.lower():
76
+ data['four'] = file
77
+ elif 'me' in file.lower():
78
+ data['me'] = file
79
+ elif 'one' in file.lower():
80
+ data['one'] = file
81
+ elif 'small' in file.lower():
82
+ data['small'] = file
83
+
84
+ yield idx, data