vkashko commited on
Commit
36cd1ee
·
1 Parent(s): dbf9108

fix: script

Browse files
data/presentation-attack-detection-2d-dataset.csv CHANGED
@@ -1,15 +1,15 @@
1
- set_id,worker_id,age,gender,country
2
- 000269e00f--64c8d84d089f4e44f6481bb0,87284a341d43afbbdab0e50ca251d0a4,29,MALE,TR
3
- 000269e00f--64c8f4db4a10835184c95641,be29b530751176898fc789fd05a9c7f5,31,FEMALE,RU
4
- 000269e00f--64c8f55c64b09d4014084391,44617ee2c5d73df66092a16d5f31cc01,31,MALE,RU
5
- 000269e00f--64c9cbf134a9be2301431749,a584def9dac1981eab24fe5f49d14f41,20,FEMALE,RU
6
- 000269e00f--64ca0aa684be481f7568360f,bd3d36b02696f6306ebbe24470e39360,33,NULL,KZ
7
- 000269e00f--64ca72f2c38b125fffa93c6e,22b51caa31b5cbb85543724dd638161b,33,MALE,RU
8
- 000269e00f--64caa8acb4858c670df55582,333563ad329ed488f987582afe1a08d8,23,FEMALE,RU
9
- 000269e00f--64cb61c13dc862273921414f,2bc6b8bf0f8b96b5ca977264e23309c4,18,NULL,RU
10
- 000269e00f--64cbccc402343312e74eccfb,666df1bb2ab0bbb8eadb2f56c139494a,44,FEMALE,RU
11
- 000269e00f--64cce2f9747ca45dad369280,8a1401b507e0cd65b4d42d7dd71a64a2,38,FEMALE,RU
12
- 000269e00f--64ce34be591a914f7a454dae,36277a2ea9a122d816b1b1b3e2eaa178,21,MALE,RU
13
- 000269e00f--64cf6c2ca3e04150ef4c19c2,450ce6a2a97424d4ecae0e95df862ba5,23,FEMALE,RU
14
- 000269e00f--64d1d284038f0820fecdab8b,81338ba7fc06c99471d04f99c4ee7740,38,MALE,RU
15
- 000269e00f--64d25998571de06b0eecc774,08ac2144aacba85a377efedb9875b1c9,28,FEMALE,RU
 
1
+ video,set_id,worker_id,age,gender,country
2
+ 000269e00f--64c8d84d089f4e44f6481bb0/3.mp4,000269e00f--64c8d84d089f4e44f6481bb0,87284a341d43afbbdab0e50ca251d0a4,29,MALE,TR
3
+ 000269e00f--64c8f4db4a10835184c95641/3.mp4,be29b530751176898fc789fd05a9c7f5,31,FEMALE,RU
4
+ 000269e00f--64c8f55c64b09d4014084391/3.mp4,44617ee2c5d73df66092a16d5f31cc01,31,MALE,RU
5
+ 000269e00f--64c9cbf134a9be2301431749/3.mp4,a584def9dac1981eab24fe5f49d14f41,20,FEMALE,RU
6
+ 000269e00f--64ca0aa684be481f7568360f/3.MOV,bd3d36b02696f6306ebbe24470e39360,33,NULL,KZ
7
+ 000269e00f--64ca72f2c38b125fffa93c6e/3.mp4,22b51caa31b5cbb85543724dd638161b,33,MALE,RU
8
+ 000269e00f--64caa8acb4858c670df55582/3.mp4,333563ad329ed488f987582afe1a08d8,23,FEMALE,RU
9
+ 000269e00f--64cb61c13dc862273921414f/3.mp4,2bc6b8bf0f8b96b5ca977264e23309c4,18,NULL,RU
10
+ 000269e00f--64cbccc402343312e74eccfb/3.mp4,666df1bb2ab0bbb8eadb2f56c139494a,44,FEMALE,RU
11
+ 000269e00f--64cce2f9747ca45dad369280/3.mp4,8a1401b507e0cd65b4d42d7dd71a64a2,38,FEMALE,RU
12
+ 000269e00f--64ce34be591a914f7a454dae/3.mp4,36277a2ea9a122d816b1b1b3e2eaa178,21,MALE,RU
13
+ 000269e00f--64cf6c2ca3e04150ef4c19c2/3.MOV,450ce6a2a97424d4ecae0e95df862ba5,23,FEMALE,RU
14
+ 000269e00f--64d1d284038f0820fecdab8b/3.mp4,81338ba7fc06c99471d04f99c4ee7740,38,MALE,RU
15
+ 000269e00f--64d25998571de06b0eecc774/3.mp4,08ac2144aacba85a377efedb9875b1c9,28,FEMALE,RU
presentation-attack-detection-2d-dataset.py CHANGED
@@ -1,4 +1,4 @@
1
- from itertools import pairwise
2
 
3
  import datasets
4
  import pandas as pd
@@ -59,25 +59,26 @@ class PresentationAttackDetection2dDataset(datasets.GeneratorBasedBuilder):
59
 
60
  def _generate_examples(self, attacks, annotations):
61
  annotations_df = pd.read_csv(annotations, sep=",")
62
- for idx, ((image_path, image), (video_path, video)) in enumerate(
63
- pairwise(attacks)
64
- ):
65
- yield idx, {
66
- "photo": {"path": image_path, "bytes": image.read()},
67
- "video": video_path,
68
- "worker_id": annotations_df.loc[
69
- annotations_df["worker_id"] == image_path.split("/")[-2]
70
- ]["worker_id"].values[0],
71
- "set_id": annotations_df.loc[
72
- annotations_df["worker_id"] == image_path.split("/")[-2]
73
- ]["set_id"].values[0],
74
- "age": annotations_df.loc[
75
- annotations_df["worker_id"] == image_path.split("/")[-2]
76
- ]["age"].values[0],
77
- "country": annotations_df.loc[
78
- annotations_df["worker_id"] == image_path.split("/")[-2]
79
- ]["country"].values[0],
80
- "gender": annotations_df.loc[
81
- annotations_df["worker_id"] == image_path.split("/")[-2]
82
- ]["gender"].values[0],
83
- }
 
 
1
+ from itertools import count
2
 
3
  import datasets
4
  import pandas as pd
 
59
 
60
  def _generate_examples(self, attacks, annotations):
61
  annotations_df = pd.read_csv(annotations, sep=",")
62
+ for idx, (image_path, image) in enumerate(attacks):
63
+ if image_path.endswith('jpg'):
64
+ yield idx, {
65
+ "photo": {"path": image_path, "bytes": image},
66
+ "video": annotations_df.loc[
67
+ annotations_df["set_id"].where(lambda x: x in image_path)
68
+ ]["video"].values[0],
69
+ "worker_id": annotations_df.loc[
70
+ annotations_df["set_id"].where(lambda x: x in image_path)
71
+ ]["worker_id"].values[0],
72
+ "set_id": annotations_df.loc[
73
+ annotations_df["set_id"].where(lambda x: x in image_path)
74
+ ]["set_id"].values[0],
75
+ "age": annotations_df.loc[
76
+ annotations_df["set_id"].where(lambda x: x in image_path)
77
+ ]["age"].values[0],
78
+ "country": annotations_df.loc[
79
+ annotations_df["set_id"].where(lambda x: x in image_path)
80
+ ]["country"].values[0],
81
+ "gender": annotations_df.loc[
82
+ annotations_df["set_id"].where(lambda x: x in image_path)
83
+ ]["gender"].values[0],
84
+ }