mirror of
https://github.com/PaddlePaddle/PaddleOCR.git
synced 2025-06-03 21:53:39 +08:00
Improve package import compatibility (#10052)
This update is to fix package import compatibility issue, such as paddleocr & detectron2. with this updates, detectron2 can be imported along side with paddleocr.
This commit is contained in:
parent
013870d9bc
commit
44316ac7fd
14
paddleocr.py
14
paddleocr.py
@ -27,9 +27,17 @@ import logging
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
tools = importlib.import_module('.', 'tools')
|
def _import_file(module_name, file_path, make_importable=False):
|
||||||
ppocr = importlib.import_module('.', 'ppocr')
|
spec = importlib.util.spec_from_file_location(module_name, file_path)
|
||||||
ppstructure = importlib.import_module('.', 'ppstructure')
|
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')
|
||||||
|
|
||||||
from tools.infer import predict_system
|
from tools.infer import predict_system
|
||||||
from ppocr.utils.logging import get_logger
|
from ppocr.utils.logging import get_logger
|
||||||
|
Loading…
x
Reference in New Issue
Block a user