diff --git a/paddleocr.py b/paddleocr.py index 96a641bb774152b26aa7a0d4f206403368e7f257..9ad8f578087a786978919edc2de35f5aa18258a3 100644 --- a/paddleocr.py +++ b/paddleocr.py @@ -30,12 +30,17 @@ import base64 from io import BytesIO from PIL import Image -tools = importlib.import_module('.', 'tools') -ppocr = importlib.import_module('.', 'ppocr') -ppstructure = importlib.import_module('.', 'ppstructure') - -from tools.infer import predict_system -from ppocr.utils.logging import get_logger +def _import_file(module_name, file_path, make_importable=False): + spec = importlib.util.spec_from_file_location(module_name, file_path) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + if make_importable: + sys.modules[module_name] = module + return module + +tools = _import_file('tools', os.path.join(__dir__, 'tools/__init__.py'), make_importable=True) +ppocr = importlib.import_module('ppocr', 'paddleocr') +ppstructure = importlib.import_module('ppstructure', 'paddleocr') logger = get_logger() from ppocr.utils.utility import check_and_read, get_image_file_list