Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the issue of ernie-layout model inference error cause by invalid… #5866

Merged
merged 3 commits into from
May 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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