PaddleHub multi_languages_ocr_db_crnn类型错误

laik7k3q  于 5个月前  发布在  其他
关注(0)|答案(1)|浏览(43)

我在ai studio上使用paddlehub的multi_languages_ocr_db_crnn,但是出现报错如下:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_26157/1143782944.py in <module>
      3 
      4 ocr = hub.Module(name="multi_languages_ocr_db_crnn", lang='en')       # mkldnn加速仅在CPU下有效
----> 5 result = ocr.recognize_text(paths=['/home/aistudio/test/test4.jpg'])

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/compat/paddle_utils.py in runner(*args, **kwargs)
    219     def runner(*args, **kwargs):
    220         with static_mode_guard():
--> 221             return func(*args, **kwargs)
    222 
    223     return runner

~/.paddlehub/modules/multi_languages_ocr_db_crnn/module.py in recognize_text(self, images, paths, output_dir, visualization)
     95                     boxes = line[0]
     96                     text, score = line[1]
---> 97                     rec_res_final.append({'text': text, 'confidence': float(score), 'text_box_position': boxes})
     98                 elif self.det and not self.rec:
     99                     boxes = line

TypeError: float() argument must be a string or a number, not 'tuple'

我的环境为:
paddlepaddle-ocr 2.4.0.post112
paddlehub 2.3.0
paddleocr 2.5.0.2

41zrol4v

41zrol4v1#

import cv2

ocr = hub.Module(name="multi_languages_ocr_db_crnn", lang='en', enable_mkldnn=True)       # mkldnn加速仅在CPU下有效
result = ocr.recognize_text(paths=['/home/aistudio/test/test4.jpg'])```
这是我的代码

相关问题