PaddlePaddle / PaddleOCR

Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
https://paddlepaddle.github.io/PaddleOCR/
Apache License 2.0
42.57k stars 7.67k forks source link

PaddleOCR freezes on MacOs Ventura M1 #8938

Closed felixgao closed 4 months ago

felixgao commented 1 year ago

请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem

This is a two part problem.

  1. new install causes cv2 error
  2. after downgrade cv2, it freezes the code

after the installation the test fails with cv2

❯ pytest -s test_paddle.py
ImportError while loading conftest '/Users/ggao/github/ged/libs/ocr/tests/conftest.py'.
conftest.py:2: in <module>
    import cv2
../.venv/lib/python3.10/site-packages/cv2/__init__.py:181: in <module>
    bootstrap()
../.venv/lib/python3.10/site-packages/cv2/__init__.py:175: in bootstrap
    if __load_extra_py_code_for_module("cv2", submodule, DEBUG):
../.venv/lib/python3.10/site-packages/cv2/__init__.py:28: in __load_extra_py_code_for_module
    py_module = importlib.import_module(module_name)
../.venv/lib/python3.10/site-packages/cv2/gapi/__init__.py:301: in <module>
    cv.gapi.wip.GStreamerPipeline = cv.gapi_wip_gst_GStreamerPipeline
E   AttributeError: partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline' (most likely due to a circular import)

to avoid that problem downgraded opencv to a lower version • Updating opencv-python (4.7.0.68 -> 4.5.5.64)

then the code stuck in this state with 100% cpu usage and freezes the process.

test_paddle.py [2023/01/31 16:17:06] ppocr DEBUG: Namespace(help='==SUPPRESS==', use_gpu=False, use_xpu=False, use_npu=False, ir_optim=True, use_tensorrt=False, min_subgraph_size=15, precision='fp32', gpu_mem=500, image_dir=None, page_num=0, det_algorithm='DB', det_model_dir='/Users/ggao/.paddleocr/whl/det/en/en_PP-OCRv3_det_infer', det_limit_side_len=960, det_limit_type='max', det_box_type='quad', det_db_thresh=0.3, det_db_box_thresh=0.6, det_db_unclip_ratio=1.5, max_batch_size=10, use_dilation=False, det_db_score_mode='fast', det_east_score_thresh=0.8, det_east_cover_thresh=0.1, det_east_nms_thresh=0.2, det_sast_score_thresh=0.5, det_sast_nms_thresh=0.2, det_pse_thresh=0, det_pse_box_thresh=0.85, det_pse_min_area=16, det_pse_scale=1, scales=[8, 16, 32], alpha=1.0, beta=1.0, fourier_degree=5, rec_algorithm='SVTR_LCNet', rec_model_dir='/Users/ggao/.paddleocr/whl/rec/en/en_PP-OCRv3_rec_infer', rec_image_inverse=True, rec_image_shape='3, 48, 320', rec_batch_num=6, max_text_length=25, rec_char_dict_path='/Users/ggao/intuit/github/ged/GED_MONOREPO/libs/ocr/.venv/lib/python3.10/site-packages/paddleocr/ppocr/utils/en_dict.txt', use_space_char=True, vis_font_path='./doc/fonts/simfang.ttf', drop_score=0.5, e2e_algorithm='PGNet', e2e_model_dir=None, e2e_limit_side_len=768, e2e_limit_type='max', e2e_pgnet_score_thresh=0.5, e2e_char_dict_path='./ppocr/utils/ic15_dict.txt', e2e_pgnet_valid_set='totaltext', e2e_pgnet_mode='fast', use_angle_cls=False, cls_model_dir='/Users/ggao/.paddleocr/whl/cls/ch_ppocr_mobile_v2.0_cls_infer', cls_image_shape='3, 48, 192', label_list=['0', '180'], cls_batch_num=6, cls_thresh=0.9, enable_mkldnn=False, cpu_threads=10, use_pdserving=False, warmup=False, sr_model_dir=None, sr_image_shape='3, 32, 128', sr_batch_num=1, draw_img_save_dir='./inference_results', save_crop_res=False, crop_res_save_dir='./output', use_mp=False, total_process_num=1, process_id=0, benchmark=False, save_log_path='./log_output/', show_log=True, use_onnx=False, output='./output', table_max_len=488, table_algorithm='TableAttn', table_model_dir=None, merge_no_span_structure=True, table_char_dict_path=None, layout_model_dir=None, layout_dict_path=None, layout_score_threshold=0.5, layout_nms_threshold=0.5, kie_algorithm='LayoutXLM', ser_model_dir=None, re_model_dir=None, use_visual_backbone=True, ser_dict_path='../train_data/XFUND/class_list_xfun.txt', ocr_order_method=None, mode='structure', image_orientation=False, layout=True, table=True, ocr=True, recovery=False, use_pdf2docx_api=False, lang='en', det=True, rec=True, type='ocr', ocr_version='PP-OCRv3', structure_version='PP-StructureV2')
jingsongliujing commented 1 year ago

pip install opencv-python install "opencv-python-headless<4.3

felixgao commented 1 year ago

installed headless

pip install "opencv-python-headless<4.3"
Collecting opencv-python-headless<4.3
  Downloading opencv_python_headless-3.4.18.65-cp37-abi3-macosx_11_0_arm64.whl (28.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 28.2/28.2 MB 17.7 MB/s eta 0:00:00
Requirement already satisfied: numpy>=1.14.5 in ./.venv/lib/python3.10/site-packages (from opencv-python-headless<4.3) (1.24.1)
Installing collected packages: opencv-python-headless
  Attempting uninstall: opencv-python-headless
    Found existing installation: opencv-python-headless 4.5.4.60
    Uninstalling opencv-python-headless-4.5.4.60:
      Successfully uninstalled opencv-python-headless-4.5.4.60
Successfully installed opencv-python-headless-3.4.18.65
 pip freeze
aiofiles==22.1.0
aiohttp==3.7.4.post0
aiosignal==1.3.1
altair==4.2.2
anyio==3.6.2
appnope==0.1.3
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
arrow==1.2.3
astor==0.8.1
asttokens==2.2.1
async-timeout==3.0.1
attrdict==2.0.1
attrs==22.2.0
Babel==2.11.0
backcall==0.2.0
bce-python-sdk==0.8.74
beautifulsoup4==4.11.1
bleach==6.0.0
boto3==1.26.60
botocore==1.29.60
Brotli==1.0.9
cachetools==5.3.0
certifi==2022.12.7
cffi==1.15.1
chardet==4.0.0
charset-normalizer==3.0.1
click==8.1.3
comm==0.1.2
contourpy==1.0.7
cssselect==1.2.0
cssutils==2.6.0
cycler==0.11.0
Cython==0.29.33
debugpy==1.6.6
decorator==5.1.1
defusedxml==0.7.1
dill==0.3.6
easyocr==1.6.2
entrypoints==0.4
et-xmlfile==1.1.0
exceptiongroup==1.1.0
executing==1.2.0
fastapi==0.89.1
fastjsonschema==2.16.2
ffmpy==0.3.0
fire==0.5.0
Flask==2.2.2
flask-babel==3.0.1
fonttools==4.38.0
fqdn==1.5.1
frozenlist==1.3.3
fsspec==2023.1.0
future==0.18.3
gevent==22.10.2
geventhttpclient==2.0.8
google-api-core==2.11.0
google-auth==2.16.0
google-cloud-vision==2.8.0
googleapis-common-protos==1.58.0
gradio==3.17.0
greenlet==2.0.2
grpcio==1.41.0
grpcio-status==1.41.0
h11==0.14.0
httpcore==0.16.3
httpx==0.23.3
idna==3.4
imageio==2.25.0
imgaug==0.4.0
iniconfig==2.0.0
ipykernel==6.21.0
ipython==8.9.0
ipython-genutils==0.2.0
ipywidgets==8.0.4
isoduration==20.11.0
itsdangerous==2.1.2
jedi==0.18.2
Jinja2==3.1.2
jmespath==1.0.1
jsonpointer==2.3
jsonschema==4.17.3
jupyter==1.0.0
jupyter-console==6.4.4
jupyter-events==0.6.3
jupyter_client==8.0.2
jupyter_core==5.2.0
jupyter_server==2.1.0
jupyter_server_terminals==0.4.4
jupyterlab-pygments==0.2.2
jupyterlab-widgets==3.0.5
kiwisolver==1.4.4
linkify-it-py==1.0.3
lmdb==1.4.0
loguru==0.6.0
lxml==4.9.2
markdown-it-py==2.1.0
MarkupSafe==2.1.2
matplotlib==3.6.3
matplotlib-inline==0.1.6
mdit-py-plugins==0.3.3
mdurl==0.1.2
mistune==2.0.4
mpmath==1.2.1
multidict==6.0.4
multiprocess==0.70.14
nbclassic==0.5.1
nbclient==0.7.2
nbconvert==7.2.9
nbformat==5.7.3
nest-asyncio==1.5.6
networkx==3.0
ninja==1.11.1
notebook==6.5.2
notebook_shim==0.2.2
numpy==1.24.1
onnx==1.12.0
opencv-contrib-python==4.7.0.68
opencv-python==4.5.5.64
opencv-python-headless==3.4.18.65
openpyxl==3.1.0
opt-einsum==3.3.0
orjson==3.8.5
packaging==23.0
paddle-bfloat==0.1.7
paddleocr==2.6.1.2
paddlepaddle==2.4.1
pandas==1.5.3
pandocfilters==1.5.0
parso==0.8.3
pdf2docx==0.5.6
pexpect==4.8.0
pickleshare==0.7.5
Pillow==9.4.0
platformdirs==2.6.2
pluggy==1.0.0
premailer==3.10.0
prometheus-client==0.16.0
prompt-toolkit==3.0.36
proto-plus==1.22.2
protobuf==3.19.6
psutil==5.9.4
ptyprocess==0.7.0
pure-eval==0.2.2
pyasn1==0.4.8
pyasn1-modules==0.2.8
pyclipper==1.3.0.post4
pycparser==2.21
pycryptodome==3.17
pydantic==1.10.4
pydub==0.25.1
Pygments==2.14.0
PyMuPDF==1.20.2
pyobjc-core==9.0.1
pyobjc-framework-Cocoa==9.0.1
pyobjc-framework-CoreML==9.0.1
pyobjc-framework-Quartz==9.0.1
pyobjc-framework-Vision==9.0.1
pyocr==0.8.3
pyparsing==3.0.9
pyrsistent==0.19.3
pytest==7.2.1
python-bidi==0.4.2
python-dateutil==2.8.2
python-docx==0.8.11
python-json-logger==2.0.4
python-multipart==0.0.5
python-rapidjson==1.9
pytz==2022.7.1
PyWavelets==1.4.1
PyYAML==6.0
pyzmq==25.0.0
qtconsole==5.4.0
QtPy==2.3.0
rapidfuzz==2.13.7
rarfile==4.0
requests==2.28.2
rfc3339-validator==0.1.4
rfc3986==1.5.0
rfc3986-validator==0.1.1
rsa==4.9
s3transfer==0.6.0
scikit-image==0.19.3
scipy==1.10.0
Send2Trash==1.8.0
Shapely==1.8.5.post1
six==1.16.0
sniffio==1.3.0
soupsieve==2.3.2.post1
stack-data==0.6.2
starlette==0.22.0
sympy==1.11.1
termcolor==2.2.0
terminado==0.17.1
tifffile==2023.1.23.1
tinycss2==1.2.1
tomli==2.0.1
toolz==0.12.0
torch==1.13.1
torchvision==0.14.1
tornado==6.2
tqdm==4.64.1
traitlets==5.9.0
tritonclient==2.23.0
typing_extensions==4.4.0
uc-micro-py==1.0.1
uri-template==1.2.0
urllib3==1.26.14
uvicorn==0.20.0
visualdl==2.5.0
wcwidth==0.2.6
webcolors==1.12
webencodings==0.5.1
websocket-client==1.5.0
websockets==10.4
Werkzeug==2.2.2
widgetsnbextension==4.0.5
wurlitzer==3.0.3
x2paddle==1.4.0
yarl==1.8.2
zope.event==4.6
zope.interface==5.5.2

still seems hanging with the CPU at 100%

matteocontrini commented 1 year ago

Same issue here.

yaowt05 commented 1 year ago

I have the same problem paddleocr 2.6.1.3 opencv-python 4.6.0.66

tobytang1987 commented 1 year ago

Any update on this?

Same issue here with below environments,

macOS: 13.3.1 (a) python: 3.8.16 paddleocr: 2.6.1.3 opencv-python-headless: 3.4.18.65

Execute command: paddleocr --image_dir resource/img/page.png --use_angle_cls false --lang en --use_gpu false

Got console result: [2023/05/12 10:16:37] ppocr DEBUG: Namespace(alpha=1.0, benchmark=False, beta=1.0, cls_batch_num=6, cls_image_shape='3, 48, 192', cls_model_dir='~/.paddleocr/whl/cls/ch_ppocr_mobile_v2.0_cls_infer', cls_thresh=0.9, cpu_threads=10, crop_res_save_dir='./output', det=True, det_algorithm='DB', det_box_type='quad', det_db_box_thresh=0.6, det_db_score_mode='fast', det_db_thresh=0.3, det_db_unclip_ratio=1.5, det_east_cover_thresh=0.1, det_east_nms_thresh=0.2, det_east_score_thresh=0.8, det_limit_side_len=960, det_limit_type='max', det_model_dir='~/.paddleocr/whl/det/en/en_PP-OCRv3_det_infer', det_pse_box_thresh=0.85, det_pse_min_area=16, det_pse_scale=1, det_pse_thresh=0, det_sast_nms_thresh=0.2, det_sast_score_thresh=0.5, draw_img_save_dir='./inference_results', drop_score=0.5, e2e_algorithm='PGNet', e2e_char_dict_path='./ppocr/utils/ic15_dict.txt', e2e_limit_side_len=768, e2e_limit_type='max', e2e_model_dir=None, e2e_pgnet_mode='fast', e2e_pgnet_score_thresh=0.5, e2e_pgnet_valid_set='totaltext', enable_mkldnn=False, fourier_degree=5, gpu_mem=500, help='==SUPPRESS==', image_dir='resource/img/page.png', image_orientation=False, ir_optim=True, kie_algorithm='LayoutXLM', label_list=['0', '180'], lang='en', layout=True, layout_dict_path=None, layout_model_dir=None, layout_nms_threshold=0.5, layout_score_threshold=0.5, max_batch_size=10, max_text_length=25, merge_no_span_structure=True, min_subgraph_size=15, mode='structure', ocr=True, ocr_order_method=None, ocr_version='PP-OCRv3', output='./output', page_num=0, precision='fp32', process_id=0, re_model_dir=None, rec=True, rec_algorithm='SVTR_LCNet', rec_batch_num=6, rec_char_dict_path='~/venv/lib/python3.8/site-packages/paddleocr/ppocr/utils/en_dict.txt', rec_image_inverse=True, rec_image_shape='3, 48, 320', rec_model_dir='~/.paddleocr/whl/rec/en/en_PP-OCRv3_rec_infer', recovery=False, save_crop_res=False, save_log_path='./log_output/', scales=[8, 16, 32], ser_dict_path='../train_data/XFUND/class_list_xfun.txt', ser_model_dir=None, show_log=True, sr_batch_num=1, sr_image_shape='3, 32, 128', sr_model_dir=None, structure_version='PP-StructureV2', table=True, table_algorithm='TableAttn', table_char_dict_path=None, table_max_len=488, table_model_dir=None, total_process_num=1, type='ocr', use_angle_cls=False, use_dilation=False, use_gpu=False, use_mp=False, use_npu=False, use_onnx=False, use_pdf2docx_api=False, use_pdserving=False, use_space_char=True, use_tensorrt=False, use_visual_backbone=True, use_xpu=False, vis_font_path='./doc/fonts/simfang.ttf', warmup=False) [2023/05/12 10:16:37] ppocr INFO: **********resource/img/page.png**********

hanging here with the CPU at 100%.

ariefwijaya commented 1 year ago

The problem solved when I install this package paddlepaddle-2.4.2-cp310-cp310-macosx_10_14_universal2.whl

tomriddly commented 1 year ago

The problem solved when I install this package paddlepaddle-2.4.2-cp310-cp310-macosx_10_14_universal2.whl

where did you get this? Facing the same issue and not able to find this package

tokyomap commented 1 year ago

The problem solved when I install this package paddlepaddle-2.4.2-cp310-cp310-macosx_10_14_universal2.whl

Can you share this file or a link to it?

Cupcee commented 1 year ago

I have this problem too. No solutions work that I've tried

f497196689 commented 11 months ago

same problem

zrp2023 commented 8 months ago

pip install opencv-python install "opencv-python-headless<4.3

maybe useful

nashlibby commented 8 months ago

after pip install opencv-python install "opencv-python-headless<4.3, new problem: Illegal instruction

UserWangZz commented 4 months ago

It has not been updated for a long time. This issue is temporarily closed and can be reopened if necessary.