From 39ac3b5ab470e68dc1af5adaadd2de027bf4c5c7 Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Tue, 2 Nov 2021 16:10:43 +0800 Subject: [PATCH] pse post-processing is only compiled when needed --- ppocr/postprocess/__init__.py | 14 ++++++++------ ppocr/postprocess/pse_postprocess/pse/__init__.py | 5 +++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ppocr/postprocess/__init__.py b/ppocr/postprocess/__init__.py index 5ca4e6bb..c6cb0144 100644 --- a/ppocr/postprocess/__init__.py +++ b/ppocr/postprocess/__init__.py @@ -18,7 +18,6 @@ from __future__ import print_function from __future__ import unicode_literals import copy -import platform __all__ = ['build_post_process'] @@ -26,21 +25,24 @@ from .db_postprocess import DBPostProcess, DistillationDBPostProcess from .east_postprocess import EASTPostProcess from .sast_postprocess import SASTPostProcess from .rec_postprocess import CTCLabelDecode, AttnLabelDecode, SRNLabelDecode, DistillationCTCLabelDecode, \ - TableLabelDecode, NRTRLabelDecode, SARLabelDecode , SEEDLabelDecode + TableLabelDecode, NRTRLabelDecode, SARLabelDecode, SEEDLabelDecode from .cls_postprocess import ClsPostProcess from .pg_postprocess import PGPostProcess -from .pse_postprocess import PSEPostProcess def build_post_process(config, global_config=None): support_dict = [ - 'DBPostProcess', 'PSEPostProcess', 'EASTPostProcess', 'SASTPostProcess', - 'CTCLabelDecode', 'AttnLabelDecode', 'ClsPostProcess', 'SRNLabelDecode', - 'PGPostProcess', 'DistillationCTCLabelDecode', 'TableLabelDecode', + 'DBPostProcess', 'EASTPostProcess', 'SASTPostProcess', 'CTCLabelDecode', + 'AttnLabelDecode', 'ClsPostProcess', 'SRNLabelDecode', 'PGPostProcess', + 'DistillationCTCLabelDecode', 'TableLabelDecode', 'DistillationDBPostProcess', 'NRTRLabelDecode', 'SARLabelDecode', 'SEEDLabelDecode' ] + if config['name'] == 'PSEPostProcess': + from .pse_postprocess import PSEPostProcess + support_dict.append('PSEPostProcess') + config = copy.deepcopy(config) module_name = config.pop('name') if global_config is not None: diff --git a/ppocr/postprocess/pse_postprocess/pse/__init__.py b/ppocr/postprocess/pse_postprocess/pse/__init__.py index 0536a32e..1903a914 100644 --- a/ppocr/postprocess/pse_postprocess/pse/__init__.py +++ b/ppocr/postprocess/pse_postprocess/pse/__init__.py @@ -21,8 +21,9 @@ ori_path = os.getcwd() os.chdir('ppocr/postprocess/pse_postprocess/pse') if subprocess.call( '{} setup.py build_ext --inplace'.format(python_path), shell=True) != 0: - raise RuntimeError('Cannot compile pse: {}'.format( - os.path.dirname(os.path.realpath(__file__)))) + raise RuntimeError( + 'Cannot compile pse: {}, if your system is windows, you need to install all the default components of `desktop development using C++` in visual studio 2019+'. + format(os.path.dirname(os.path.realpath(__file__)))) os.chdir(ori_path) from .pse import pse -- GitLab