Skip to content

Commit b3954d3

Browse files
authored
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
1 parent 6954da7 commit b3954d3

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

paddleocr.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from pathlib import Path
3030
import base64
3131
from io import BytesIO
32+
import pprint
3233
from PIL import Image
3334
from tools.infer import predict_system
3435

@@ -889,17 +890,10 @@ def main():
889890
)
890891
if result is not None:
891892
lines = []
892-
for idx in range(len(result)):
893-
res = result[idx]
893+
for res in result:
894894
for line in res:
895895
logger.info(line)
896-
val = "["
897-
for box in line[0]:
898-
val += str(box[0]) + "," + str(box[1]) + ","
899-
900-
val = val[:-1]
901-
val += "]," + line[1][0] + "," + str(line[1][1]) + "\n"
902-
lines.append(val)
896+
lines.append(pprint.pformat(line) + "\n")
903897
if args.savefile:
904898
if os.path.exists(args.output) is False:
905899
os.mkdir(args.output)
@@ -941,7 +935,6 @@ def main():
941935
all_res = []
942936
for index, (new_img_path, img) in enumerate(img_paths):
943937
logger.info("processing {}/{} page:".format(index + 1, len(img_paths)))
944-
new_img_name = os.path.basename(new_img_path).split(".")[0]
945938
result = engine(img, img_idx=index)
946939
save_structure_res(result, args.output, img_name, index)
947940

0 commit comments

Comments
 (0)