From e785bb116341d35f144bbf9d5dcbbf92c96cb233 Mon Sep 17 00:00:00 2001 From: BinChen <38782567+ChenBinfighting1@users.noreply.github.com> Date: Mon, 7 Nov 2022 10:32:14 +0800 Subject: [PATCH] box2example ori_boxes+ (#3677) Co-authored-by: x-shadow-man <1494445739@qq.com> --- paddlenlp/taskflow/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/paddlenlp/taskflow/utils.py b/paddlenlp/taskflow/utils.py index 9343c3edff45..0d6d920fb31a 100644 --- a/paddlenlp/taskflow/utils.py +++ b/paddlenlp/taskflow/utils.py @@ -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 @@ -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))) @@ -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,