Anonymous commited on
Commit
c0d6f1c
·
verified ·
1 Parent(s): 2774f6c

Update nova.py

Browse files
Files changed (1) hide show
  1. nova.py +6 -2
nova.py CHANGED
@@ -36,6 +36,9 @@ class NovaDataset(GeneratorBasedBuilder):
36
  )
37
 
38
  def _split_generators(self, dl_manager):
 
 
 
39
  # Download CSVs
40
  csvs = {
41
  "captions": dl_manager.download("captions.csv"),
@@ -49,7 +52,7 @@ class NovaDataset(GeneratorBasedBuilder):
49
  return [
50
  SplitGenerator(
51
  name=Split.TEST,
52
- gen_kwargs={"image_dir": image_dir, "csvs": csvs},
53
  )
54
  ]
55
 
@@ -70,13 +73,14 @@ class NovaDataset(GeneratorBasedBuilder):
70
  ).to_dict()
71
  meta = meta.set_index("case_id").to_dict("index")
72
 
 
73
 
74
  for idx, row in captions.iterrows():
75
  filename = row["filename"]
76
  case_id = row["case_id"]
77
  image_path = os.path.join(image_dir, filename)
78
  record = {
79
- "image": image_path,
80
  "filename": filename,
81
  "caption": row["caption"],
82
  "case_id": case_id,
 
36
  )
37
 
38
  def _split_generators(self, dl_manager):
39
+ archive_path = dl_manager.download_and_extract("test/Images.zip")
40
+ image_files = list(dl_manager.iter_files(archive_path))
41
+
42
  # Download CSVs
43
  csvs = {
44
  "captions": dl_manager.download("captions.csv"),
 
52
  return [
53
  SplitGenerator(
54
  name=Split.TEST,
55
+ gen_kwargs={"image_files": image_files, "csvs": csvs},
56
  )
57
  ]
58
 
 
73
  ).to_dict()
74
  meta = meta.set_index("case_id").to_dict("index")
75
 
76
+ images_map = {os.path.basename(f): f for f in image_files}
77
 
78
  for idx, row in captions.iterrows():
79
  filename = row["filename"]
80
  case_id = row["case_id"]
81
  image_path = os.path.join(image_dir, filename)
82
  record = {
83
+ "image": images_map.get(filename, None),
84
  "filename": filename,
85
  "caption": row["caption"],
86
  "case_id": case_id,