Datasets:
Commit
·
e921172
1
Parent(s):
50a901d
Update DocLayNet-small.py
Browse files- DocLayNet-small.py +8 -8
DocLayNet-small.py
CHANGED
@@ -121,7 +121,7 @@ class DocLayNet(datasets.GeneratorBasedBuilder):
|
|
121 |
)
|
122 |
),
|
123 |
"image": datasets.features.Image(),
|
124 |
-
"pdf": datasets.Value("string"),
|
125 |
"page_hash": datasets.Value("string"), # unique identifier, equal to filename
|
126 |
"original_filename": datasets.Value("string"), # original document filename
|
127 |
"page_no": datasets.Value("int32"), # page number in original document
|
@@ -211,12 +211,12 @@ class DocLayNet(datasets.GeneratorBasedBuilder):
|
|
211 |
image_path = image_path.replace("json", "png")
|
212 |
image, size = load_image(image_path)
|
213 |
|
214 |
-
# get pdf
|
215 |
-
pdf_path = os.path.join(pdf_dir, file)
|
216 |
-
pdf_path = pdf_path.replace("json", "pdf")
|
217 |
-
with open(pdf_path, "rb") as pdf_file:
|
218 |
-
|
219 |
-
|
220 |
|
221 |
for item in data["form"]:
|
222 |
text_example, category_example, bbox_block_example, bbox_line_example = item["text"], item["category"], item["box"], item["box_line"]
|
@@ -237,4 +237,4 @@ class DocLayNet(datasets.GeneratorBasedBuilder):
|
|
237 |
collection = data["metadata"]["collection"]
|
238 |
doc_category = data["metadata"]["doc_category"]
|
239 |
|
240 |
-
yield guid, {"id": str(guid), "texts": texts, "bboxes_block": bboxes_block, "bboxes_line": bboxes_line, "categories": categories, "image": image, "
|
|
|
121 |
)
|
122 |
),
|
123 |
"image": datasets.features.Image(),
|
124 |
+
#"pdf": datasets.Value("string"),
|
125 |
"page_hash": datasets.Value("string"), # unique identifier, equal to filename
|
126 |
"original_filename": datasets.Value("string"), # original document filename
|
127 |
"page_no": datasets.Value("int32"), # page number in original document
|
|
|
211 |
image_path = image_path.replace("json", "png")
|
212 |
image, size = load_image(image_path)
|
213 |
|
214 |
+
# # get pdf
|
215 |
+
# pdf_path = os.path.join(pdf_dir, file)
|
216 |
+
# pdf_path = pdf_path.replace("json", "pdf")
|
217 |
+
# with open(pdf_path, "rb") as pdf_file:
|
218 |
+
# pdf_bytes = pdf_file.read()
|
219 |
+
# pdf_encoded_string = base64.b64encode(pdf_bytes)
|
220 |
|
221 |
for item in data["form"]:
|
222 |
text_example, category_example, bbox_block_example, bbox_line_example = item["text"], item["category"], item["box"], item["box_line"]
|
|
|
237 |
collection = data["metadata"]["collection"]
|
238 |
doc_category = data["metadata"]["doc_category"]
|
239 |
|
240 |
+
yield guid, {"id": str(guid), "texts": texts, "bboxes_block": bboxes_block, "bboxes_line": bboxes_line, "categories": categories, "image": image, "page_hash": page_hash, "original_filename": original_filename, "page_no": page_no, "num_pages": num_pages, "original_width": original_width, "original_height": original_height, "coco_width": coco_width, "coco_height": coco_height, "collection": collection, "doc_category": doc_category}
|