PaddlePaddle/PaddleHub

paddlehub 使用模型ch_pp-ocrv3识别失败

zouxiaodong opened this issue · 1 comments

欢迎您反馈PaddleHub使用问题,非常感谢您对PaddleHub的贡献!
在留下您的问题时,辛苦您同步提供如下信息:

  • 版本、环境信息
    paddlepaddle 2.4.2 paddlehub:2.3.1
    2)系统环境:请您描述系统类型,例如Linux/Windows/MacOS/,python版本
    ubuntu 18.04

使用如下测试图片:
test

1,运行模型目录~/.paddlehub/modules/ch_pp_ocrv3下的test.py识别结果失败
python test.py
失败信息如下 : results的data为[]
FFFF..[2023-07-05 12:18:27,939] [ INFO] - Paddle Inference model saved in inference/model/_text_detector_module.
[2023-07-05 12:18:28,305] [ INFO] - Paddle Inference model saved in ./inference/model.
.E

ERROR: tearDownClass (main.TestHubModule)

Traceback (most recent call last):
File "test.py", line 30, in tearDownClass
shutil.rmtree('ocr_result')
File "/data/conda/paddlehub/lib/python3.8/shutil.py", line 709, in rmtree
onerror(os.lstat, path, sys.exc_info())
File "/data/conda/paddlehub/lib/python3.8/shutil.py", line 707, in rmtree
orig_st = os.lstat(path)
FileNotFoundError: [Errno 2] No such file or directory: 'ocr_result'

======================================================================
FAIL: test_recognize_text1 (main.TestHubModule)

Traceback (most recent call last):
File "test.py", line 38, in test_recognize_text1
self.assertEqual(results[0]['data'], [{
AssertionError: Lists differ: [] != [{'text': 'GIVE.', 'confidence': 0.9509768[202 chars]9]]}]

Second list contains 2 additional elements.
First extra element 0:
{'text': 'GIVE.', 'confidence': 0.9509768486022949, 'text_box_position': [[283, 162], [352, 162], [352, 202], [283, 202]]}

  • []
  • [{'confidence': 0.9509768486022949,
  • 'text': 'GIVE.',
  • 'text_box_position': [[283, 162], [352, 162], [352, 202], [283, 202]]},
  • {'confidence': 0.9943074584007263,
  • 'text': 'THANKS',
  • 'text_box_position': [[261, 202], [376, 202], [376, 239], [261, 239]]}]

======================================================================
FAIL: test_recognize_text2 (main.TestHubModule)

Traceback (most recent call last):
File "test.py", line 54, in test_recognize_text2
self.assertEqual(results[0]['data'], [{
AssertionError: Lists differ: [] != [{'text': 'GIVE.', 'confidence': 0.9509768[202 chars]9]]}]

Second list contains 2 additional elements.
First extra element 0:
{'text': 'GIVE.', 'confidence': 0.9509768486022949, 'text_box_position': [[283, 162], [352, 162], [352, 202], [283, 202]]}

  • []
  • [{'confidence': 0.9509768486022949,
  • 'text': 'GIVE.',
  • 'text_box_position': [[283, 162], [352, 162], [352, 202], [283, 202]]},
  • {'confidence': 0.9943074584007263,
  • 'text': 'THANKS',
  • 'text_box_position': [[261, 202], [376, 202], [376, 239], [261, 239]]}]

======================================================================
FAIL: test_recognize_text3 (main.TestHubModule)

Traceback (most recent call last):
File "test.py", line 70, in test_recognize_text3
self.assertEqual(results[0]['data'], [{
AssertionError: Lists differ: [] != [{'text': 'GIVE.', 'confidence': 0.9509768[202 chars]9]]}]

Second list contains 2 additional elements.
First extra element 0:
{'text': 'GIVE.', 'confidence': 0.9509768486022949, 'text_box_position': [[283, 162], [352, 162], [352, 202], [283, 202]]}

  • []
  • [{'confidence': 0.9509768486022949,
  • 'text': 'GIVE.',
  • 'text_box_position': [[283, 162], [352, 162], [352, 202], [283, 202]]},
  • {'confidence': 0.9943074584007263,
  • 'text': 'THANKS',
  • 'text_box_position': [[261, 202], [376, 202], [376, 239], [261, 239]]}]

======================================================================
FAIL: test_recognize_text4 (main.TestHubModule)

Traceback (most recent call last):
File "test.py", line 86, in test_recognize_text4
self.assertEqual(results[0]['data'], [{
AssertionError: Lists differ: [] != [{'text': 'GIVE.', 'confidence': 0.9509768[202 chars]9]]}]

Second list contains 2 additional elements.
First extra element 0:
{'text': 'GIVE.', 'confidence': 0.9509768486022949, 'text_box_position': [[283, 162], [352, 162], [352, 202], [283, 202]]}

  • []
  • [{'confidence': 0.9509768486022949,
  • 'text': 'GIVE.',
  • 'text_box_position': [[283, 162], [352, 162], [352, 202], [283, 202]]},
  • {'confidence': 0.9943074584007263,
  • 'text': 'THANKS',
  • 'text_box_position': [[261, 202], [376, 202], [376, 239], [261, 239]]}]

Ran 7 tests in 6.740s

FAILED (failures=4, errors=1)

2,换成本地图片也是识别不到文字,results.data 还是为[]
import paddlehub as hub
import cv2
ocr = hub.Module(name="ch_pp-ocrv3")
result = ocr.recognize_text(images=[cv2.imread("/home/robert/test.jpg")])
print(result)

[{'save_path': '', 'data': []}]

  1. hub run ch_pp-ocrv3 --input_path "/home/robert/test.jpg" ,data为[]

/data/conda/paddlehub/lib/python3.8/site-packages/pkg_resources/init.py:121: DeprecationWarning: pkg_resources is deprecated as an API
warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning)
/data/conda/paddlehub/lib/python3.8/site-packages/pkg_resources/init.py:2870: DeprecationWarning: Deprecated call to pkg_resources.declare_namespace('mpl_toolkits').
Implementing implicit namespace packages (as specified in PEP 420) is preferred to pkg_resources.declare_namespace. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
declare_namespace(pkg)
/data/conda/paddlehub/lib/python3.8/site-packages/pkg_resources/init.py:2870: DeprecationWarning: Deprecated call to pkg_resources.declare_namespace('google').
Implementing implicit namespace packages (as specified in PEP 420) is preferred to pkg_resources.declare_namespace. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
declare_namespace(pkg)
/data/conda/paddlehub/lib/python3.8/site-packages/pkg_resources/init.py:2870: DeprecationWarning: Deprecated call to pkg_resources.declare_namespace('sphinxcontrib').
Implementing implicit namespace packages (as specified in PEP 420) is preferred to pkg_resources.declare_namespace. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
declare_namespace(pkg)
/data/conda/paddlehub/lib/python3.8/site-packages/pkg_resources/init.py:2870: DeprecationWarning: Deprecated call to pkg_resources.declare_namespace('zope').
Implementing implicit namespace packages (as specified in PEP 420) is preferred to pkg_resources.declare_namespace. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
declare_namespace(pkg)
/data/conda/paddlehub/lib/python3.8/site-packages/_distutils_hack/init.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
[{'save_path': '', 'data': []}]

gpu 环境不行,cpu环境是可以的,我再检测一下GPU环境到底那出问题了