24
24
sys .path .append (os .path .join (__dir__ , "" ))
25
25
26
26
import cv2
27
+ from copy import deepcopy
27
28
import logging
28
29
import numpy as np
29
30
from pathlib import Path
@@ -65,6 +66,7 @@ def _import_file(module_name, file_path, make_importable=False):
65
66
from tools .infer .utility import draw_ocr , str2bool , check_gpu
66
67
from ppstructure .utility import init_args , draw_structure_result
67
68
from ppstructure .predict_system import StructureSystem , save_structure_res , to_excel
69
+ from ppstructure .recovery .recovery_to_doc import sorted_layout_boxes , convert_info_docx
68
70
69
71
logger = get_logger ()
70
72
@@ -76,6 +78,8 @@ def _import_file(module_name, file_path, make_importable=False):
76
78
"save_structure_res" ,
77
79
"download_with_progressbar" ,
78
80
"to_excel" ,
81
+ "sorted_layout_boxes" ,
82
+ "convert_info_docx" ,
79
83
]
80
84
81
85
SUPPORT_DET_MODEL = ["DB" ]
@@ -939,18 +943,13 @@ def main():
939
943
save_structure_res (result , args .output , img_name , index )
940
944
941
945
if args .recovery and result != []:
942
- from copy import deepcopy
943
- from ppstructure .recovery .recovery_to_doc import sorted_layout_boxes
944
-
945
946
h , w , _ = img .shape
946
947
result_cp = deepcopy (result )
947
948
result_sorted = sorted_layout_boxes (result_cp , w )
948
949
all_res += result_sorted
949
950
950
951
if args .recovery and all_res != []:
951
952
try :
952
- from ppstructure .recovery .recovery_to_doc import convert_info_docx
953
-
954
953
convert_info_docx (img , all_res , args .output , img_name )
955
954
except Exception as ex :
956
955
logger .error (
0 commit comments