Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions paddlex/inference/pipelines/layout_parsing/pipeline_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,11 +689,15 @@ def get_layout_parsing_objects(
- "block_bbox": The coordinates of the layout box.
"""

table_index = 0
table_cell_bboxes_list = [
[[int(pos) for pos in box] for box in table_res["cell_box_list"]]
for table_res in table_res_list
] if table_res_list else []
table_bboxes = [calculate_minimum_enclosing_bbox(table_cell_bboxes)
for table_cell_bboxes in table_cell_bboxes_list]
seal_index = 0
chart_index = 0
layout_parsing_blocks: List[LayoutBlock] = []

for box_idx, box_info in enumerate(layout_det_res["boxes"]):

label = box_info["label"]
Expand All @@ -703,8 +707,10 @@ def get_layout_parsing_objects(
block = LayoutBlock(label=label, bbox=block_bbox)

if label == "table" and len(table_res_list) > 0:
# The table index is obtained by calculating the overlap ratio between the bounding boxes of the tables.
table_overlap_ratio_list = [calculate_overlap_ratio(bbox1=block_bbox, bbox2=table_bbox) for table_bbox in table_bboxes]
table_index, table_overlap_ratio = max(enumerate(table_overlap_ratio_list), key=lambda x: x[1])
block.content = table_res_list[table_index]["pred_html"]
table_index += 1
elif label == "seal" and len(seal_res_list) > 0:
block.content = "\n".join(seal_res_list[seal_index]["rec_texts"])
seal_index += 1
Expand Down