PaddleOCR icon indicating copy to clipboard operation
PaddleOCR copied to clipboard

Unable to run PaddleOCR on Macbook Pro M3 Pro (Apple Silicon, Arch: arm)

Open vikasr111 opened this issue 1 year ago • 4 comments

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

  • 系统环境/System Environment:Macbook Pro M3 Pro (Apple Silicon, Arch: arm)
  • System OS: MacOS Sonoma 14.1 (23B2073)
  • Python version: 3.10.13
  • 版本号/Version:Paddle:2.6.0 PaddleOCR:2.7.0.3 问题相关组件/Related components:
  • 运行指令/Command Code: Here's my full code:
from paddleocr import PaddleOCR
DATA_DIR = "data"
OUTPUT_DIR = "output"
FONT_PATH = "./fonts/simfang.ttf"

ocr = PaddleOCR(use_angle_cls=True)

def paddle_ocr(filename):
    filepath = os.path.join(DATA_DIR, filename)
    output_filename = os.path.splitext(filename)[0] + "-paddle.txt"
    output_path = os.path.join(OUTPUT_DIR, output_filename)

    if not os.path.exists(filepath):
        print(f"File {filename} not found in {DATA_DIR}.")
        return

    result = ocr.ocr(filepath, cls=True)
    detected_text = ""
    for idx in range(len(result)):
        page_text = "\n".join([item[1][0] for item in result[idx]])
        detected_text += f"\n------------------\n{page_text}"

    with open(output_path, "w") as f:
        f.write(detected_text)

    print(f"Processed {filename} and saved to {output_filename}")
  • 完整报错/Complete Error Message: When I try to run the code above in main.py, the paddleOCR initializes with all the parameters but after that it gets stuck. I don't see the next step where it downloads default models

  • Additional info: I have already checked the platform in the terminal before running the above code. The python platform shows: arm:

import platform
print(f"Platform: {platform.processor()}")
// Platform: arm

我们提供了AceIssueSolver来帮助你解答问题,你是否想要它来解答(请填写yes/no)?/We provide AceIssueSolver to solve issues, do you want it? (Please write yes/no): yes

请尽量不要包含图片在问题中/Please try to not include the image in the issue.

vikasr111 avatar Feb 09 '24 16:02 vikasr111

@paddle-bot @tink2123 I managed to install and setup PaddleOCR. Now when I try to run PaddleOCR on any document, the PaddleOCR gets initialized and I see following log in the console:

2024/02/09 14:51:30] 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, gpu_id=0, image_dir=None, page_num=0, det_algorithm='DB', det_model_dir='/Users/Cipher/.paddleocr/whl/det/ch/ch_PP-OCRv4_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/Cipher/.paddleocr/whl/rec/ch/ch_PP-OCRv4_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/Cipher/AssistCX/ocr-parser/.venv/lib/python3.10/site-packages/paddleocr/ppocr/utils/ppocr_keys_v1.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=True, cls_model_dir='/Users/Cipher/.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, invert=False, binarize=False, alphacolor=(255, 255, 255), lang='ch', det=True, rec=True, type='ocr', ocr_version='PP-OCRv4', structure_version='PP-StructureV2')

But it gets stuck after this forever. I don't see any log for model download or OCR operation. Even ctrl+c to terminate operation does not work. Please help me identify the problem and fix it.

vikasr111 avatar Feb 09 '24 20:02 vikasr111

@paddle-bot @tink2123 I managed to install and setup PaddleOCR. Now when I try to run PaddleOCR on any document, the PaddleOCR gets initialized and I see following log in the console:

2024/02/09 14:51:30] 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, gpu_id=0, image_dir=None, page_num=0, det_algorithm='DB', det_model_dir='/Users/Cipher/.paddleocr/whl/det/ch/ch_PP-OCRv4_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/Cipher/.paddleocr/whl/rec/ch/ch_PP-OCRv4_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/Cipher/AssistCX/ocr-parser/.venv/lib/python3.10/site-packages/paddleocr/ppocr/utils/ppocr_keys_v1.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=True, cls_model_dir='/Users/Cipher/.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, invert=False, binarize=False, alphacolor=(255, 255, 255), lang='ch', det=True, rec=True, type='ocr', ocr_version='PP-OCRv4', structure_version='PP-StructureV2')

But it gets stuck after this forever. I don't see any log for model download or OCR operation. Even ctrl+c to terminate operation does not work. Please help me identify the problem and fix it.

i have the same problem

s33you avatar Feb 19 '24 09:02 s33you

Having the exact same issue, is there any workaround?

alouafi avatar Feb 26 '24 15:02 alouafi

cc: @michaelowenliu

jzhang533 avatar Feb 28 '24 05:02 jzhang533

Can you verify whether Paddle is installed correctly?

Try running in python interpreter

import paddle
paddle.utils.run_check()

tink2123 avatar Mar 01 '24 06:03 tink2123

related: #11079

jzhang533 avatar Mar 01 '24 06:03 jzhang533

We currently do not support the M-series system, but it is in our scheduling plan. Thank you for your interest.

tink2123 avatar Mar 01 '24 06:03 tink2123