vkashko commited on
Commit
605c58e
1 Parent(s): 7bc140e

fix: sorting

Browse files
facial-emotion-recognition-dataset.py CHANGED
@@ -72,12 +72,13 @@ class FacialEmotionRecognitionDataset(datasets.GeneratorBasedBuilder):
72
 
73
  def _generate_examples(self, images, annotations):
74
  annotations_df = pd.read_csv(annotations, sep=';')
 
75
  images = sorted(images)
76
  images = [images[i:i + 8] for i in range(0, len(images), 8)]
77
 
78
  for idx, images_set in enumerate(images):
79
- # set_id = int(images_set[0].split('/')[-2])
80
- data = {'set_id': idx}
81
 
82
  for file in images_set:
83
  if 'neutral' in file.lower():
@@ -98,10 +99,10 @@ class FacialEmotionRecognitionDataset(datasets.GeneratorBasedBuilder):
98
  data['surprised'] = file
99
 
100
  data['age'] = annotations_df.loc[annotations_df['set_id'] ==
101
- idx]['age'].values[0]
102
  data['gender'] = annotations_df.loc[annotations_df['set_id'] ==
103
- idx]['gender'].values[0]
104
  data['country'] = annotations_df.loc[annotations_df['set_id'] ==
105
- idx]['country'].values[0]
106
 
107
  yield idx, data
 
72
 
73
  def _generate_examples(self, images, annotations):
74
  annotations_df = pd.read_csv(annotations, sep=';')
75
+
76
  images = sorted(images)
77
  images = [images[i:i + 8] for i in range(0, len(images), 8)]
78
 
79
  for idx, images_set in enumerate(images):
80
+ set_id = int(images_set[0].split('/')[-2])
81
+ data = {'set_id': set_id}
82
 
83
  for file in images_set:
84
  if 'neutral' in file.lower():
 
99
  data['surprised'] = file
100
 
101
  data['age'] = annotations_df.loc[annotations_df['set_id'] ==
102
+ set_id]['age'].values[0]
103
  data['gender'] = annotations_df.loc[annotations_df['set_id'] ==
104
+ set_id]['gender'].values[0]
105
  data['country'] = annotations_df.loc[annotations_df['set_id'] ==
106
+ set_id]['country'].values[0]
107
 
108
  yield idx, data