weixin_65616955 2025-06-12 16:51 采纳率: 0%
浏览 55

PaddleOCR 搭建好测试时运行成功,但没有输出结果,result文件显示test1.png []

参考https://blog.csdn.net/qq_52852432/article/details/131817619?ops_request_misc=%257B%2522request%255Fid%2522%253A%25224ee48ceef1c49f73c0c3f818cbf3dfa9%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=4ee48ceef1c49f73c0c3f818cbf3dfa9&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~top_positive~default-1-131817619-null-null.142^v102^pc_search_result_base9&utm_term=paddleocr&spm=1018.2226.3001.4187

等文章搭建好paddleOCR后

无论是命令行:

>python tools/infer/predict_system.py --image_dir="C:\Users\PC\Desktop\test1.png" --det_model_dir="D:/PaddleOCR-2.6/inference/ch_ppocr_mobile_v2.0_det_infer"  --rec_model_dir="D:/PaddleOCR-2.6/inference/ch_ppocr_mobile_v2.0_rec_infer" --cls_model_dir="D:/PaddleOCR-2.6/inference/ch_ppocr_mobile_v2.0_cls_infer" --use_angle_cls=True --use_space_char=False --use_gpu=True

还是代码里

from paddleocr import PaddleOCR
ocr = PaddleOCR(use_angle_cls=True, lang="ch", det_model_dir="D:/PaddleOCR-2.6/inference/ch_ppocr_mobile_v2.0_det_infer", rec_model_dir="D:/PaddleOCR-2.6/inference/ch_ppocr_mobile_v2.0_rec_infer",
                cls_model_dir="D:/PaddleOCR-2.6/inference/ch_ppocr_mobile_v2.0_cls_infer")
img_path = 'C:/Users/PC/Desktop/test1.png'
result = ocr.ocr(img_path, cls=False)
for line in result:
    print(line)

都能运行成功,显示:

[2025/06/12 16:22:39] ppocr DEBUG: dt_boxes num : 3, elapse : 1.6964607238769531
[2025/06/12 16:22:39] ppocr DEBUG: cls num  : 3, elapse : 0.028058290481567383
[2025/06/12 16:22:40] ppocr DEBUG: rec_res num  : 3, elapse : 0.23061299324035645
[2025/06/12 16:22:40] ppocr DEBUG: 0  Predict time of C:\Users\PC\Desktop\test1.png: 1.955s
[2025/06/12 16:22:40] ppocr DEBUG: The visualized image saved in ./inference_results\test1.png
[2025/06/12 16:22:40] ppocr INFO: The predict total time is 1.959130048751831

可是没有识别结果,result文件里也显示test1.png []
尝试过修改cls=False 还是不能解决问题
请问大家怎么解决这个问题呀

  • 写回答

6条回答 默认 最新

  • 阿里嘎多学长 2025-06-12 16:51
    关注

    阿里嘎多学长整理AIGC生成,因移动端显示问题导致当前答案未能完全显示,请使用PC端查看更加详细的解答过程

    问题解答

    PaddleOCR搭建成功后没有输出结果,这可能是因为在配置文件中没有正确地指定输出结果的路径。

    在 PaddleOCR 的配置文件中,通常需要指定 output_diroutput_file 两个参数来指定输出结果的路径和文件名。例如:

    model_config = {
        'model': 'ocr',
        'model_path': 'path/to/model',
        'output_dir': 'path/to/output',
        'output_file': 'result.png'
    }
    

    在上面的配置文件中,output_dir 指定了输出结果的目录,output_file 指定了输出结果的文件名。

    如果你已经正确地指定了输出结果的路径和文件名,但仍然没有输出结果,可以尝试检查 PaddleOCR 的日志文件,查看是否有任何错误信息。

    另外,如果你使用的是 PaddleOCR 的最新版本,可以尝试使用 paddleocr 模块的 recognize 函数来指定输出结果的路径和文件名,例如:

    import paddleocr
    
    # 创建 PaddleOCR 对象
    ocr = paddleocr.PaddleOCR()
    
    # 指定输出结果的路径和文件名
    output_dir = 'path/to/output'
    output_file = 'result.png'
    
    # 执行 OCR 操作
    result = ocr.recognize(image_path, output_dir=output_dir, output_file=output_file)
    

    在上面的代码中,output_diroutput_file 参数指定了输出结果的路径和文件名。

    评论

报告相同问题?

问题事件

  • 创建了问题 6月12日