Skip to content

Commit 72e02f5

Browse files
committed
fix layout recovery import error (#13434)
1 parent 40c5662 commit 72e02f5

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

__init__.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,24 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
from .paddleocr import *
14+
from .paddleocr import (
15+
PaddleOCR,
16+
PPStructure,
17+
draw_ocr,
18+
draw_structure_result,
19+
save_structure_res,
20+
download_with_progressbar,
21+
sorted_layout_boxes,
22+
convert_info_docx,
23+
to_excel,
24+
)
1525
import importlib.metadata as importlib_metadata
1626

1727
try:
1828
__version__ = importlib_metadata.version(__package__ or __name__)
1929
except importlib_metadata.PackageNotFoundError:
2030
__version__ = "0.0.0"
31+
2132
__all__ = [
2233
"PaddleOCR",
2334
"PPStructure",

paddleocr.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
sys.path.append(os.path.join(__dir__, ""))
2525

2626
import cv2
27+
from copy import deepcopy
2728
import logging
2829
import numpy as np
2930
from pathlib import Path
@@ -65,6 +66,7 @@ def _import_file(module_name, file_path, make_importable=False):
6566
from tools.infer.utility import draw_ocr, str2bool, check_gpu
6667
from ppstructure.utility import init_args, draw_structure_result
6768
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
6870

6971
logger = get_logger()
7072

@@ -76,6 +78,8 @@ def _import_file(module_name, file_path, make_importable=False):
7678
"save_structure_res",
7779
"download_with_progressbar",
7880
"to_excel",
81+
"sorted_layout_boxes",
82+
"convert_info_docx",
7983
]
8084

8185
SUPPORT_DET_MODEL = ["DB"]
@@ -939,18 +943,13 @@ def main():
939943
save_structure_res(result, args.output, img_name, index)
940944

941945
if args.recovery and result != []:
942-
from copy import deepcopy
943-
from ppstructure.recovery.recovery_to_doc import sorted_layout_boxes
944-
945946
h, w, _ = img.shape
946947
result_cp = deepcopy(result)
947948
result_sorted = sorted_layout_boxes(result_cp, w)
948949
all_res += result_sorted
949950

950951
if args.recovery and all_res != []:
951952
try:
952-
from ppstructure.recovery.recovery_to_doc import convert_info_docx
953-
954953
convert_info_docx(img, all_res, args.output, img_name)
955954
except Exception as ex:
956955
logger.error(

0 commit comments

Comments
 (0)