PaddlePaddle / PaddleHub

Awesome pre-trained models toolkit based on PaddlePaddle. (400+ models including Image, Text, Audio, Video and Cross-Modal with Easy Inference & Serving)【安全加固,暂停交互,请耐心等待】
https://www.paddlepaddle.org.cn/hub
Apache License 2.0
12.74k stars 2.07k forks source link

multi_languages_ocr_db_crnn类型错误 #2221

Open xiehuanyi opened 1 year ago

xiehuanyi commented 1 year ago

我在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

xiehuanyi commented 1 year ago

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'])```
这是我的代码