jordyvl commited on
Commit
c640b0d
1 Parent(s): dbea5d2

Refer to v1.06 in DUDE loader

Browse files
Files changed (2) hide show
  1. DUDE_imdb_loader.py +17 -6
  2. DUDE_loader.py +1 -1
DUDE_imdb_loader.py CHANGED
@@ -240,9 +240,20 @@ def create_imdb_record_from_json(
240
  else:
241
  answers = None
242
 
243
- if include_variants and record['answers_variants']:
244
  answers += record["answers_variants"]
245
 
 
 
 
 
 
 
 
 
 
 
 
246
  # fix if wrongly saved pagenames
247
  # page_image_names = [
248
  # split + image_name for image_name in page_image_names if image_name.startswith("/")
@@ -260,9 +271,9 @@ def create_imdb_record_from_json(
260
  "answers": answers, # list
261
  "answer_page": None,
262
  "extra": {
263
- # 'question_type': record['qtype'],
264
- # 'industry': record['industry'],
265
- # 'category': record['category'],
266
  "answer_type": record["answer_type"],
267
  },
268
  }
@@ -426,7 +437,7 @@ if __name__ == "__main__":
426
  print(f"Loading from disk: {imdb_filename}")
427
  imdb = np.load(imdb_filename, allow_pickle=True)
428
 
429
- else:
430
  imdb = create_imdb_from_json(
431
  dataset[split], # .select(split_indices),
432
  documents_metadata=documents_metadata,
@@ -436,4 +447,4 @@ if __name__ == "__main__":
436
  include_answers=True,
437
  include_variants=(not args.no_include_variants),
438
  )
439
- np.save(imdb_filename, imdb)
 
240
  else:
241
  answers = None
242
 
243
+ if include_variants and record["answers_variants"] and not 'list' in record['answer_type']:
244
  answers += record["answers_variants"]
245
 
246
+ page_image_dir = "/".join(record["document"].split("/")[:-2]).replace("PDF", "images")
247
+ if not page_image_names or any(
248
+ [not os.path.exists(os.path.join(page_image_dir, p)) for p in page_image_names]
249
+ ):
250
+ print(
251
+ "Missing images: ",
252
+ docId,
253
+ #[p for p in page_image_names if not os.path.exists(os.path.join(page_image_dir, p))],
254
+ )
255
+ return {}
256
+
257
  # fix if wrongly saved pagenames
258
  # page_image_names = [
259
  # split + image_name for image_name in page_image_names if image_name.startswith("/")
 
271
  "answers": answers, # list
272
  "answer_page": None,
273
  "extra": {
274
+ #'question_type': record['qtype'],
275
+ #'industry': record['industry'],
276
+ #'category': record['category'],
277
  "answer_type": record["answer_type"],
278
  },
279
  }
 
437
  print(f"Loading from disk: {imdb_filename}")
438
  imdb = np.load(imdb_filename, allow_pickle=True)
439
 
440
+ else:
441
  imdb = create_imdb_from_json(
442
  dataset[split], # .select(split_indices),
443
  documents_metadata=documents_metadata,
 
447
  include_answers=True,
448
  include_variants=(not args.no_include_variants),
449
  )
450
+ np.save(imdb_filename, imdb)
DUDE_loader.py CHANGED
@@ -49,7 +49,7 @@ _URLS = {
49
  # "binaries": "https://huggingface.co/datasets/jordyvl/DUDE_loader/resolve/main/data/DUDE_binaries.tar.gz", #
50
  # "annotations": "https://huggingface.co/datasets/jordyvl/DUDE_loader/resolve/main/data/DUDE_dataset-sample_gt.json" #"
51
  "binaries": "https://huggingface.co/datasets/jordyvl/DUDE_loader/resolve/main/data/DUDE_train-val-test_binaries.tar.gz", # DUDE_train-val-test_binaries.tar.gz
52
- "annotations": "https://zenodo.org/record/7667761/files/DUDE_gt_release-candidate_trainval.json?download=1",
53
  }
54
 
55
  SKIP_DOC_IDS = ["ef03364aa27a0987c9870472e312aceb", "5c5a5880e6a73b4be2315d506ab0b15b"]
 
49
  # "binaries": "https://huggingface.co/datasets/jordyvl/DUDE_loader/resolve/main/data/DUDE_binaries.tar.gz", #
50
  # "annotations": "https://huggingface.co/datasets/jordyvl/DUDE_loader/resolve/main/data/DUDE_dataset-sample_gt.json" #"
51
  "binaries": "https://huggingface.co/datasets/jordyvl/DUDE_loader/resolve/main/data/DUDE_train-val-test_binaries.tar.gz", # DUDE_train-val-test_binaries.tar.gz
52
+ "annotations": "https://zenodo.org/record/7680589/files/DUDE_gt_release-candidate_trainval.json?download=1",
53
  }
54
 
55
  SKIP_DOC_IDS = ["ef03364aa27a0987c9870472e312aceb", "5c5a5880e6a73b4be2315d506ab0b15b"]