roopalgarg commited on
Commit
b3a0a94
1 Parent(s): 568e9cd

add urls feature for LocNar validation set.

Browse files
Files changed (1) hide show
  1. imageinwords.py +3 -0
imageinwords.py CHANGED
@@ -69,6 +69,7 @@ _DATASET_FEATURES = {
69
  }),
70
  "LocNar_Eval": datasets.Features({
71
  "image/key": datasets.Value('string'),
 
72
  "IIW-P5B": datasets.Value('string'),
73
  }),
74
  }
@@ -77,6 +78,7 @@ _DATASET_FEATURES = {
77
  _CM_3600_URL_PATTERN = string.Template("https://open-images-dataset.s3.amazonaws.com/crossmodal-3600/$IMAGE_KEY.jpg")
78
  _DOCCI_AAR_URL_PATTERN = string.Template("https://storage.googleapis.com/docci/data/images_aar/$IMAGE_KEY.jpg")
79
  _DOCCI_THUMBNAIL_URL_PATTERN = string.Template("https://storage.googleapis.com/docci/thumbnails/$IMAGE_KEY.jpg")
 
80
 
81
 
82
  class ImageInWords(datasets.GeneratorBasedBuilder):
@@ -165,5 +167,6 @@ class ImageInWords(datasets.GeneratorBasedBuilder):
165
  with open(filepath) as fp:
166
  for json_line in fp:
167
  json_obj = json.loads(json_line.strip())
 
168
  del json_obj["image/source"]
169
  yield json_obj["image/key"], json_obj
 
69
  }),
70
  "LocNar_Eval": datasets.Features({
71
  "image/key": datasets.Value('string'),
72
+ "image/url": datasets.Value('string'),
73
  "IIW-P5B": datasets.Value('string'),
74
  }),
75
  }
 
78
  _CM_3600_URL_PATTERN = string.Template("https://open-images-dataset.s3.amazonaws.com/crossmodal-3600/$IMAGE_KEY.jpg")
79
  _DOCCI_AAR_URL_PATTERN = string.Template("https://storage.googleapis.com/docci/data/images_aar/$IMAGE_KEY.jpg")
80
  _DOCCI_THUMBNAIL_URL_PATTERN = string.Template("https://storage.googleapis.com/docci/thumbnails/$IMAGE_KEY.jpg")
81
+ _LOCNAR_VALIDATION_URL_PATTERN = string.Template("https://open-images-dataset.s3.amazonaws.com/validation/$IMAGE_KEY.jpg")
82
 
83
 
84
  class ImageInWords(datasets.GeneratorBasedBuilder):
 
167
  with open(filepath) as fp:
168
  for json_line in fp:
169
  json_obj = json.loads(json_line.strip())
170
+ json_obj["image/url"] = _LOCNAR_VALIDATION_URL_PATTERN.substitute(IMAGE_KEY=json_obj["image/key"])
171
  del json_obj["image/source"]
172
  yield json_obj["image/key"], json_obj