[PaddlePaddle/PaddleOCR]无法返回 ocr 结果

2024-05-14 816 views
3
  • 版本号/Version:

    Flask==2.1.1
    gunicorn==19.9.0
    requests==2.22.0
    opencv-python==4.5.5.64
    Pillow==7.2.0
    paddleocr==2.6.0
    paddlenlp==2.4.9
    paddlepaddle-gpu==2.3.2
    typing_extensions==4.4.0
  • 完整报错/Complete Error Message:

    [2023-02-27 17:13:55 +0800] [178] [INFO] Booting worker with pid: 178
    [2023-02-27 17:13:58,680] [ WARNING] - The schema has not been set yet, please set a schema via set_schema(). More details about the setting of schema please refer to https://github.com/PaddlePaddle/PaddleNLP/blob/develop/applications/information_extraction/taskflow_text.md
    [2023-02-27 17:14:01,826] [    INFO] - We are using <class 'paddlenlp.transformers.ernie.tokenizer.ErnieTokenizer'> to load './checkpoint/model_best'.
    [2023/02/27 17:14:01] ppocr DEBUG: Namespace(alpha=1.0, benchmark=False, beta=1.0, cls_batch_num=6, cls_image_shape='3, 48, 192', cls_model_dir='/workspace/inference/cls', cls_thresh=0.9, cpu_threads=10, crop_res_save_dir='./output', det=True, det_algorithm='DB', 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_fce_box_type='poly', det_limit_side_len=960, det_limit_type='max', det_model_dir='/workspace/inference/det', det_pse_box_thresh=0.85, det_pse_box_type='quad', det_pse_min_area=16, det_pse_scale=1, det_pse_thresh=0, det_sast_nms_thresh=0.2, det_sast_polygon=False, 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=None, image_orientation=False, ir_optim=True, kie_algorithm='LayoutXLM', label_list=['0', '180'], lang='ch', 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', precision='fp32', process_id=0, rec=True, rec_algorithm='SVTR_LCNet', rec_batch_num=6, rec_char_dict_path='/usr/local/lib/python3.7/dist-packages/paddleocr/ppocr/utils/ppocr_keys_v1.txt', rec_image_shape='3, 48, 320', rec_model_dir='/workspace/inference/rec', recovery=False, save_crop_res=False, save_log_path='./log_output/', save_pdf=False, scales=[8, 16, 32], ser_dict_path='../train_data/XFUND/class_list_xfun.txt', ser_model_dir=None, shape_info_filename=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=True, use_dilation=False, use_gpu=True, use_mp=False, use_onnx=False, use_pdserving=False, use_space_char=True, use_tensorrt=False, use_xpu=False, vis_font_path='./doc/fonts/simfang.ttf', warmup=False)

回答

0

我使用Flask搭建了个ocr的接口,现在运行起来只有这个日志,也没返回结果

6

现在我切换到cpu上测试,结果为空

image
8

从日志上看,检测到了6个框,识别的结果也有6个;

image

可以检查下是不是没有获取到结果

或者去掉flask,单独运行paddleocr试试?

2

我是直接打印了下面代码的结果

        result = paddle_ocr.ocr(os.path.dirname(__file__) + f'/{file_name}.jpg', cls=True)
4

使用同一张图片,结果是空的

image

使用官方demo:

image
9

现在的问题是我用cpu就有结果,我在gpu就没结果,也没报错信息 这里改成true就没结果了

image
0

你的是什么硬件

8
image
4

Dockerfile:

FROM registry.baidubce.com/paddlepaddle/paddle:2.4.1-gpu-cuda11.2-cudnn8.2-trt8.0

requirement.txt:

Flask==2.1.1
gunicorn==19.9.0
requests==2.22.0
opencv-python==4.5.5.64
Pillow==7.2.0
paddleocr==2.6.1.2
paddlenlp==2.4.9
paddlepaddle-gpu==2.4.1.post112
typing_extensions==4.4.0
3

我测试了一样的docker环境,我这边可以出结果 paddleocr --image_dir=./PaddleOCR/doc/imgs/11.jpg --use_gpu=True 也不会是GPU的问题;

可以pip3.7 show paddleocr 找到paddleocr的安装位置,比如,/usr/local/lib/python3.7/dist-packages/paddleocr/paddleocr.py

找到PaddleOCR这个类,在类中加一些print 看下,是在哪里没有得到输出的;

image
7

cuda 11.0,对应的paddle版本应该用哪个啊,哪里可以查到这个对应关系

7

在官网查看https://www.paddlepaddle.org.cn/

image
5

现在的问题是我用cpu就有结果,我在gpu就没结果,也没报错信息 这里改成true就没结果了

image

你怎么解决的? 我也是gpu 没结果

4

paddleocr.py文件中 661行 dt_boxes, recres, = self.call(img, cls) if not dt_boxes and not rec_res: 这一步就没有返回结果了