Leyo HF staff commited on
Commit
0d63227
1 Parent(s): 1d7dcf0

bring back images

Browse files
Files changed (1) hide show
  1. SNLI-VE.py +7 -13
SNLI-VE.py CHANGED
@@ -62,10 +62,11 @@ _SNLI_VE_SPLITS = {
62
  "validation": "snli_ve_dev.jsonl",
63
  "test": "snli_ve_test.jsonl",
64
  }
65
- # JZ_FOLDER_PATH = f"{os.environ['cnw_ALL_CCFRSCRATCH']}/local_datasets/flickr30k-images.tar.gz"
66
 
67
  _FEATURES = datasets.Features(
68
- {
 
69
  "filename": datasets.Value("string"),
70
  "premise": datasets.Value("string"),
71
  "hypothesis": datasets.Value("string"),
@@ -77,15 +78,7 @@ _FEATURES = datasets.Features(
77
  class SNLIVE(datasets.GeneratorBasedBuilder):
78
  """SNLIVE."""
79
 
80
- # @property
81
- # def manual_download_instructions(self):
82
- # return """\
83
- # In order to get the flickr data on which SNLI-VE is built, You need to go to http://shannon.cs.illinois.edu/DenotationGraph/data/index.html,
84
- # and manually download the dataset ("Flickr 30k images."). Once it is completed,
85
- # a file named `flickr30k-images.tar.gz` will appear in your Downloads folder
86
- # or whichever folder your browser chooses to save files to.
87
- # Then, the dataset can be loaded using the following command `datasets.load_dataset("flickr30k", data_dir="<path/to/folder>")`.
88
- # """
89
  DEFAULT_CONFIG_NAME = "Default"
90
  logger.warning("HER0")
91
  def _info(self):
@@ -108,7 +101,7 @@ class SNLIVE(datasets.GeneratorBasedBuilder):
108
  },
109
  }
110
  snli_ve_annotation_path = dl_manager.download_and_extract(urls)
111
- images_path = "" # dl_manager.download_and_extract(JZ_FOLDER_PATH)
112
 
113
  return [
114
  datasets.SplitGenerator(
@@ -142,8 +135,9 @@ class SNLIVE(datasets.GeneratorBasedBuilder):
142
  for elem in json_file:
143
  elem = json.loads(elem)
144
  img_filename = str(elem["Flickr30K_ID"]) + ".jpg"
145
- # assert os.path.exists(os.path.join(images_path, img_filename))
146
  record = {
 
147
  "filename": img_filename,
148
  "premise": elem["sentence1"],
149
  "hypothesis": elem["sentence2"],
 
62
  "validation": "snli_ve_dev.jsonl",
63
  "test": "snli_ve_test.jsonl",
64
  }
65
+ JZ_FOLDER_PATH = f"{os.environ['cnw_ALL_CCFRSCRATCH']}/local_datasets/flickr30k-images.tar.gz"
66
 
67
  _FEATURES = datasets.Features(
68
+ {
69
+ "image": datasets.Image(),
70
  "filename": datasets.Value("string"),
71
  "premise": datasets.Value("string"),
72
  "hypothesis": datasets.Value("string"),
 
78
  class SNLIVE(datasets.GeneratorBasedBuilder):
79
  """SNLIVE."""
80
 
81
+
 
 
 
 
 
 
 
 
82
  DEFAULT_CONFIG_NAME = "Default"
83
  logger.warning("HER0")
84
  def _info(self):
 
101
  },
102
  }
103
  snli_ve_annotation_path = dl_manager.download_and_extract(urls)
104
+ images_path = dl_manager.download_and_extract(JZ_FOLDER_PATH)
105
 
106
  return [
107
  datasets.SplitGenerator(
 
135
  for elem in json_file:
136
  elem = json.loads(elem)
137
  img_filename = str(elem["Flickr30K_ID"]) + ".jpg"
138
+ assert os.path.exists(os.path.join(images_path, img_filename))
139
  record = {
140
+ "image": img_filename,
141
  "filename": img_filename,
142
  "premise": elem["sentence1"],
143
  "hypothesis": elem["sentence2"],