[PaddlePaddle/PaddleOCR]png文件出现空指针释放,但是同一张照片转换jpg之后,并未报错

2024-05-10 422 views
3

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

png文件出现空指针释放,但是同一张照片转换jpg之后,不会报错

  • 系统环境/System Environment:Ubuntu
  • 版本号/Version:Paddle: PaddleOCR: 问题相关组件/Related components: paddleocr-2.7.3
  • 运行指令/Command Code:paddleocr --image_dir 测试面单.png --use_angle_cls true --use_gpu true
  • 完整报错/Complete Error Message:

[2024/04/27 23:05:41] ppocr DEBUG: Namespace(help='==SUPPRESS==', use_gpu=True, 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='测试面单.png', page_num=0, det_algorithm='DB', det_model_dir='/home/tanminghuan/.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='/home/tanminghuan/.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='/home/tanminghuan/anaconda3/envs/mgm/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='/home/tanminghuan/.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')
[2024/04/27 23:05:42] ppocr INFO: **********测试面单.png**********
free(): invalid pointer

--------------------------------------
C++ Traceback (most recent call last):
--------------------------------------
0   inflateReset2

----------------------
Error Message Summary:
----------------------
FatalError: `Process abort signal` is detected by the operating system.
  [TimeInfo: *** Aborted at 1714230342 (unix time) try "date -d @1714230342" if you are using GNU date ***]
  [SignalInfo: *** SIGABRT (@0x3e80008dabe) received by PID 580286 (TID 0x7641a23e4480) from PID 580286 ***]

[1]    580286 IOT instruction   paddleocr --image_di

回答

6

麻烦提供一下原图

6

辛苦提供一下测试图片,我们这边测试下,另外推理部署的话建议使用我们最新的零代码产线中的Fastdploy效果会更好哈

6

test test1

2

对应的第一个回复的图,由于权限问题无法分享。这两张也有问题,只是报错不一样:

[2024/04/28 11:57:30] ppocr INFO: **********test1.png**********
libpng error: IDAT: bad parameters to zlib
[2024/04/28 11:57:30] ppocr ERROR: error in loading image:test1.png
Traceback (most recent call last):
  File "/home/tanminghuan/anaconda3/envs/mgm/bin/paddleocr", line 8, in <module>
    sys.exit(main())
  File "/home/tanminghuan/anaconda3/envs/mgm/lib/python3.10/site-packages/paddleocr/paddleocr.py", line 794, in main
    result = engine.ocr(img_path,
  File "/home/tanminghuan/anaconda3/envs/mgm/lib/python3.10/site-packages/paddleocr/paddleocr.py", line 667, in ocr
    img = preprocess_image(img)
  File "/home/tanminghuan/anaconda3/envs/mgm/lib/python3.10/site-packages/paddleocr/paddleocr.py", line 657, in preprocess_image
    _image = alpha_to_color(_image, alpha_color)
  File "/home/tanminghuan/anaconda3/envs/mgm/lib/python3.10/site-packages/paddleocr/ppocr/utils/utility.py", line 86, in alpha_to_color
    if len(img.shape) == 3 and img.shape[2] == 4:
AttributeError: 'NoneType' object has no attribute 'shape'

转换成jpg之后识别正常。

2

无法复现这个问题

result

5

OK,应该属于环境问题,不过建议增加一个错误捕获。


[2024/04/28 13:21:57] ppocr INFO: **********test3.png**********
[2024/04/28 13:21:57] ppocr INFO: **********check_img-test3.png**********
libpng error: IDAT: bad parameters to zlib
[2024/04/28 13:21:57] ppocr ERROR: error in loading image:test3.png
[2024/04/28 13:21:57] ppocr INFO: **********check_img-None**********
[2024/04/28 13:21:57] ppocr INFO: **********None**********

check之后变成None了

4

我使用的版本

        img = check_img(img)

和线上的版本

        img, flag_gif, flag_pdf = check_img(img, alpha_color)

已经发生了很大变化,也许这个问题不能再复现了。

9

还有一个,我单独测试出错的函数img_decode是没有问题的。

In [1]: import numpy as np
   ...: import cv2
   ...:
   ...: def img_decode(content: bytes):
   ...:     np_arr = np.frombuffer(content, dtype=np.uint8)
   ...:     return cv2.imdecode(np_arr, cv2.IMREAD_UNCHANGED)
   ...:

In [2]: img_decode(open("test3.png", "rb").read())
Out[2]:
array([[[191, 130,  71, 255],
        [191, 130,  71, 255],

同样的环境,放在paddleocr就会报以上两种错误。

9

感谢讨论,鉴于问题解决,在此close该issue

4

额,好吧,我感觉没有解决,但是无法确定是否是paddleocr的问题