Skip to content

Commit

Permalink
box2example ori_boxes+ (#3677)
Browse files Browse the repository at this point in the history
Co-authored-by: x-shadow-man <1494445739@qq.com>
  • Loading branch information
ChenBinfighting1 and x-shadow-man committed Nov 7, 2022
1 parent ce31a77 commit e785bb1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions paddlenlp/taskflow/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2013,6 +2013,7 @@ def box2example(self, ocr_res, img_path, querys):
"""
examples = []
doc_boxes = []
ori_boxes = []
boxes = [x[1] for x in ocr_res]
im_w_box = max([b[2] for b in boxes]) + 20
im_h_box = max([b[3] for b in boxes]) + 20
Expand All @@ -2028,6 +2029,7 @@ def box2example(self, ocr_res, img_path, querys):
raise ValueError("Invalid bbox format")
w = max(x1, x2) - min(x1, x2)
h = max(y1, y2) - min(y1, y2)
ori_boxes.append([Bbox(*[x1, y1, w, h])])
w = int(min(w * scale_x, self.image_size - 1))
h = int(min(h * scale_y, self.image_size - 1))
x1 = int(max(0, min(x1 * scale_x, self.image_size - w - 1)))
Expand All @@ -2051,6 +2053,7 @@ def box2example(self, ocr_res, img_path, querys):
text='',
qas_id=str(qas_id),
model_type=None,
ori_boxes=ori_boxes,
boxes=doc_boxes,
segment_ids=doc_segment_ids,
symbol_ids=None,
Expand Down

0 comments on commit e785bb1

Please sign in to comment.