Skip to content

Commit 7c03c46

Browse files
fix[tableformer]: Fix cell bbox coordinates (#2)
Signed-off-by: Nikos Livathinos <[email protected]>
1 parent 9f41acc commit 7c03c46

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

docling_ibm_models/tableformer/data_management/tf_predictor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,10 @@ def _merge_tf_output(self, docling_output, pdf_cells):
437437
for pdf_cell in pdf_cells:
438438
if pdf_cell["id"] == docling_item["cell_id"]:
439439
text_cell_bbox = {
440-
"b": pdf_cell["bbox"][1],
440+
"b": pdf_cell["bbox"][3],
441441
"l": pdf_cell["bbox"][0],
442442
"r": pdf_cell["bbox"][2],
443-
"t": pdf_cell["bbox"][3],
443+
"t": pdf_cell["bbox"][1],
444444
"token": pdf_cell["text"],
445445
}
446446
tf_cells_map[cell_key]["text_cell_bboxes"].append(
@@ -468,10 +468,10 @@ def _merge_tf_output(self, docling_output, pdf_cells):
468468
for pdf_cell in pdf_cells:
469469
if pdf_cell["id"] == docling_item["cell_id"]:
470470
text_cell_bbox = {
471-
"b": pdf_cell["bbox"][1],
471+
"b": pdf_cell["bbox"][3],
472472
"l": pdf_cell["bbox"][0],
473473
"r": pdf_cell["bbox"][2],
474-
"t": pdf_cell["bbox"][3],
474+
"t": pdf_cell["bbox"][1],
475475
"token": pdf_cell["text"],
476476
}
477477
tf_cells_map[cell_key]["text_cell_bboxes"].append(

tests/test_tf_predictor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,9 +564,9 @@ def test_tf_predictor():
564564
# Visualization:
565565
for text_cell in response["text_cell_bboxes"]:
566566
xc0 = text_cell["l"]
567-
yc0 = text_cell["b"]
567+
yc0 = text_cell["t"]
568568
xc1 = text_cell["r"]
569-
yc1 = text_cell["t"]
569+
yc1 = text_cell["b"]
570570
img1.rectangle(((xc0, yc0), (xc1, yc1)), outline="red")
571571

572572
x0 = response["bbox"]["l"] - 6

0 commit comments

Comments
 (0)