Skip to content

Commit e785bb1

Browse files
ChenBinfighting1x-shadow-man
andauthored
box2example ori_boxes+ (#3677)
Co-authored-by: x-shadow-man <1494445739@qq.com>
1 parent ce31a77 commit e785bb1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

paddlenlp/taskflow/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,6 +2013,7 @@ def box2example(self, ocr_res, img_path, querys):
20132013
"""
20142014
examples = []
20152015
doc_boxes = []
2016+
ori_boxes = []
20162017
boxes = [x[1] for x in ocr_res]
20172018
im_w_box = max([b[2] for b in boxes]) + 20
20182019
im_h_box = max([b[3] for b in boxes]) + 20
@@ -2028,6 +2029,7 @@ def box2example(self, ocr_res, img_path, querys):
20282029
raise ValueError("Invalid bbox format")
20292030
w = max(x1, x2) - min(x1, x2)
20302031
h = max(y1, y2) - min(y1, y2)
2032+
ori_boxes.append([Bbox(*[x1, y1, w, h])])
20312033
w = int(min(w * scale_x, self.image_size - 1))
20322034
h = int(min(h * scale_y, self.image_size - 1))
20332035
x1 = int(max(0, min(x1 * scale_x, self.image_size - w - 1)))
@@ -2051,6 +2053,7 @@ def box2example(self, ocr_res, img_path, querys):
20512053
text='',
20522054
qas_id=str(qas_id),
20532055
model_type=None,
2056+
ori_boxes=ori_boxes,
20542057
boxes=doc_boxes,
20552058
segment_ids=doc_segment_ids,
20562059
symbol_ids=None,

0 commit comments

Comments
 (0)