yonatanbitton commited on
Commit
51e1265
1 Parent(s): 97747b2

Update winogavil.py

Browse files
Files changed (1) hide show
  1. winogavil.py +12 -6
winogavil.py CHANGED
@@ -57,12 +57,12 @@ class Winogavil(datasets.GeneratorBasedBuilder):
57
  def _info(self):
58
  features = datasets.Features(
59
  {
60
- "candidates": [datasets.Value("string")],
61
- # "candidates_images": [datasets.Value("string")],
62
- "candidates_images": [datasets.Image()],
63
  "cue": datasets.Value("string"),
64
- "associations": [datasets.Value("string")],
 
65
  'score_fool_the_ai': datasets.Value("float64"),
 
 
66
  'num_associations': datasets.Value("int64"),
67
  'num_candidates': datasets.Value("int64"),
68
  'solvers_jaccard_mean': datasets.Value("float64"),
@@ -108,13 +108,19 @@ class Winogavil(datasets.GeneratorBasedBuilder):
108
  # columns_to_serialize = ['candidates', 'associations']
109
  # for c in columns_to_serialize:
110
  # df[c] = df[c].apply(json.loads)
 
 
111
 
112
  for r_idx, r in df.iterrows():
113
  r_dict = r.to_dict()
114
  r_dict['candidates'] = json.loads(r_dict['candidates'])
115
  candidates_images = [os.path.join(images_dir, "winogavil_images", f"{x}.{self.IMAGE_EXTENSION}") for x in
116
  r_dict['candidates']]
117
- r_dict['candidates_images'] = candidates_images
118
  r_dict['associations'] = json.loads(r_dict['associations'])
 
 
 
 
119
  key = r['ID']
120
- yield key, r_dict
 
57
  def _info(self):
58
  features = datasets.Features(
59
  {
 
 
 
60
  "cue": datasets.Value("string"),
61
+ "candidate_images": [datasets.Image()],
62
+ "association_images": [datasets.Image()],
63
  'score_fool_the_ai': datasets.Value("float64"),
64
+ "candidates": [datasets.Value("string")],
65
+ "associations": [datasets.Value("string")],
66
  'num_associations': datasets.Value("int64"),
67
  'num_candidates': datasets.Value("int64"),
68
  'solvers_jaccard_mean': datasets.Value("float64"),
 
108
  # columns_to_serialize = ['candidates', 'associations']
109
  # for c in columns_to_serialize:
110
  # df[c] = df[c].apply(json.loads)
111
+ d_keys = ['cue', 'candidate_images', 'association_images', 'score_fool_the_ai', 'candidates', 'associations', 'num_candidates', 'num_associations', 'solvers_jaccard_mean', 'solvers_jaccard_std', 'ID']
112
+
113
 
114
  for r_idx, r in df.iterrows():
115
  r_dict = r.to_dict()
116
  r_dict['candidates'] = json.loads(r_dict['candidates'])
117
  candidates_images = [os.path.join(images_dir, "winogavil_images", f"{x}.{self.IMAGE_EXTENSION}") for x in
118
  r_dict['candidates']]
119
+ r_dict['candidate_images'] = candidates_images
120
  r_dict['associations'] = json.loads(r_dict['associations'])
121
+ association_images = [os.path.join(images_dir, "winogavil_images", f"{x}.{self.IMAGE_EXTENSION}") for x in
122
+ r_dict['associations']]
123
+ r_dict['association_images'] = association_images
124
+ relevant_r_dict = {k:v for k,v in r_dict.items() if k in d_keys}
125
  key = r['ID']
126
+ yield key, relevant_r_dict