Skip to content

Commit

Permalink
fix the issue of ernie-layout model inference error cause by invalid… (
Browse files Browse the repository at this point in the history
…#5866)

* fix the issue of ernie-layout model inference error cause by  invalid input of image (without ocr results), refer issue:#5865

* fix format check of pre-commit

* modify ppocr2example to fix bugs caused by empty ocr input
  • Loading branch information
zirui authored May 19, 2023
1 parent fa44cdc commit 3642ec5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions paddlenlp/utils/image_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,8 @@ def ppocr2example(ocr_res, img_path):
doc_tokens = []
doc_boxes = []

im_w_box = max([seg["bbox"].left + seg["bbox"].width for seg in segments]) + 20
im_h_box = max([seg["bbox"].top + seg["bbox"].height for seg in segments]) + 20
im_w_box = max([seg["bbox"].left + seg["bbox"].width for seg in segments]) + 20 if segments else 0
im_h_box = max([seg["bbox"].top + seg["bbox"].height for seg in segments]) + 20 if segments else 0
img = Image.open(img_path)
im_w, im_h = img.size
im_w, im_h = max(im_w, im_w_box), max(im_h, im_h_box)
Expand Down

0 comments on commit 3642ec5

Please sign in to comment.