You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

PaddleOCR调用predict()方法触发NotImplementedError问题求助

PaddleOCR调用predict()方法触发NotImplementedError问题求助

问题描述

我最近在做西班牙语图片的OCR识别,用的是PaddleOCR库。之前看到官方提示ocr.ocr()方法已经被废弃,推荐使用predict(),但我调用predict()时却触发了NotImplementedError,错误信息指向Paddle内部的属性转换问题,折腾了好一阵都没解决,来请教各位大佬!

我的代码实现

from paddleocr import PaddleOCR
from PIL import Image

# 初始化OCR引擎,指定西班牙语
ocr = PaddleOCR(use_textline_orientation=False, lang='es') 

# 待识别的本地图片路径
img_path = '../datos/casa_ley/febrero_2026/04022026_pagina_01.png' 
result = ocr.predict(img_path)

# 处理并保存识别结果
for res in result:
    res.print()
    res.save_to_img("output")
    res.save_to_json("output")

完整报错栈

运行到result = ocr.predict(img_path)这一行时直接报错,完整错误信息如下:

NotImplementedError                       Traceback (most recent call last)
Cell In[15], line 10
  8 # Run OCR on an image path (can be a local file or a web URL)
  9 img_path = '../datos/casa_ley/febrero_2026/04022026_pagina_01.jpg' 
---> 10 result = ocr.predict(img_path)
 12 # Print the results
 13 for res in result:

File c:\Users\angel.merino\Documents\GitHub\sina\.venv\Lib\site-packages\paddleocr\_pipelines\ocr.py:213, in PaddleOCR.predict(self, input, use_doc_orientation_classify, use_doc_unwarping, use_textline_orientation, text_det_limit_side_len, text_det_limit_type, text_det_thresh, text_det_box_thresh, text_det_unclip_ratio, text_rec_score_thresh, return_word_box)
198 def predict(
199     self,
200     input,
   (...)
211     return_word_box=None,
212 ):
--> 213     return list(
214         self.predict_iter(
215             input,
216             use_doc_orientation_classify=use_doc_orientation_classify,
217             use_doc_unwarping=use_doc_unwarping,
218             use_textline_orientation=use_textline_orientation,
219             text_det_limit_side_len=text_det_limit_side_len,
220             text_det_limit_type=text_det_limit_type,
221             text_det_thresh=text_det_thresh,
222             text_det_box_thresh=text_det_box_thresh,
223             text_det_unclip_ratio=text_det_unclip_ratio,
224             text_rec_score_thresh=text_rec_score_thresh,
225             return_word_box=return_word_box,
226         )
227     )
            
[...]

NotImplementedError: (Unimplemented) ConvertPirAttribute2RuntimeAttribute not support [pir::ArrayAttribute<pir::DoubleAttribute>]  
(at ..\paddle\fluid\framework\new_executor\instruction\onednn\onednn_instruction.cc:118)

已尝试的排查步骤

  • 确认图片路径绝对正确,png和jpg格式都试过,图片本身能正常打开
  • 严格按照官方文档要求,弃用了标记为废弃的ocr.ocr()方法,改用推荐的predict()
  • 虚拟环境里的PaddleOCR是通过pip install paddleocr最新安装的

想请教的问题

  1. 我调用predict()的方式是否正确?有没有其他官方推荐的调用方式可以替代?
  2. 这个错误看起来是Paddle内部的属性转换问题,是不是PaddlePaddle和PaddleOCR的版本不兼容导致的?如果是的话,有没有推荐的版本搭配?
  3. 有没有可能是我初始化PaddleOCR时的参数设置有问题?比如use_textline_orientation=False这个参数会不会引发冲突?

火山引擎 最新活动