axiong commited on
Commit
2fbe51b
1 Parent(s): 561e21d

Update pmc_oa.py

Browse files
Files changed (1) hide show
  1. pmc_oa.py +5 -6
pmc_oa.py CHANGED
@@ -45,7 +45,6 @@ class PMC_OA(datasets.GeneratorBasedBuilder):
45
  description=_DESCRIPTION,
46
  features=datasets.Features(
47
  {
48
- # "image_name": datasets.Value("string"),
49
  "image": datasets.Image(),
50
  "caption": datasets.Value("string"),
51
  }
@@ -59,12 +58,12 @@ class PMC_OA(datasets.GeneratorBasedBuilder):
59
  data_dir = dl_manager.download_and_extract(_URLS)
60
 
61
  return [
62
- datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": os.path.join(data_dir, "train.jsonl")}),
63
- datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": os.path.join(data_dir, "valid.jsonl")}),
64
- datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": os.path.join(data_dir, "test.jsonl")}),
65
  ]
66
 
67
- def _generate_examples(self, filepath):
68
  """This function returns the examples in the raw (text) form."""
69
  logger.info("generating examples from = %s", filepath)
70
 
@@ -72,7 +71,7 @@ class PMC_OA(datasets.GeneratorBasedBuilder):
72
  _id = 0
73
  for obj in reader:
74
  relative_image_path = obj['image']
75
- image_path = os.path.join("images", relative_image_path)
76
  caption = obj['caption']
77
  yield _id, {
78
  "image": {
 
45
  description=_DESCRIPTION,
46
  features=datasets.Features(
47
  {
 
48
  "image": datasets.Image(),
49
  "caption": datasets.Value("string"),
50
  }
 
58
  data_dir = dl_manager.download_and_extract(_URLS)
59
 
60
  return [
61
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": data_dir['train'], "image_dir": data_dir['images']}),
62
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": data_dir['valid'], "image_dir": data_dir['images']}),
63
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": data_dir['test'], "image_dir": data_dir['images']}),
64
  ]
65
 
66
+ def _generate_examples(self, filepath, image_dir):
67
  """This function returns the examples in the raw (text) form."""
68
  logger.info("generating examples from = %s", filepath)
69
 
 
71
  _id = 0
72
  for obj in reader:
73
  relative_image_path = obj['image']
74
+ image_path = os.path.join(image_dir, "caption_T060_filtered_top4_sep_v0_subfigures", relative_image_path)
75
  caption = obj['caption']
76
  yield _id, {
77
  "image": {