From b3954d38bac5521438f2eb850a458cb1de372327 Mon Sep 17 00:00:00 2001 From: Wang Xin Date: Wed, 5 Jun 2024 09:55:50 +0800 Subject: [PATCH] fix wrong output when --det=False (#12589) * fix wrong output when --det=False * using pprint to format the output * using pprint to format the output --- paddleocr.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/paddleocr.py b/paddleocr.py index 65b4c850a16..d69c8854c1d 100644 --- a/paddleocr.py +++ b/paddleocr.py @@ -29,6 +29,7 @@ from pathlib import Path import base64 from io import BytesIO +import pprint from PIL import Image from tools.infer import predict_system @@ -889,17 +890,10 @@ def main(): ) if result is not None: lines = [] - for idx in range(len(result)): - res = result[idx] + for res in result: for line in res: logger.info(line) - val = "[" - for box in line[0]: - val += str(box[0]) + "," + str(box[1]) + "," - - val = val[:-1] - val += "]," + line[1][0] + "," + str(line[1][1]) + "\n" - lines.append(val) + lines.append(pprint.pformat(line) + "\n") if args.savefile: if os.path.exists(args.output) is False: os.mkdir(args.output) @@ -941,7 +935,6 @@ def main(): all_res = [] for index, (new_img_path, img) in enumerate(img_paths): logger.info("processing {}/{} page:".format(index + 1, len(img_paths))) - new_img_name = os.path.basename(new_img_path).split(".")[0] result = engine(img, img_idx=index) save_structure_res(result, args.output, img_name, index)