2

我有一个 python 应用程序,它使用 tesseract 检测扫描图像中的复选框,在我的本地机器上运行良好,但是当我将代码连同 python-tesseract buildpack 一起推送到 Bluemix 时,它无法生成输出文件,这意味着 tesseract 不是在 Bluemix 上被检测到。

这是我的 manifest.yml:

应用程序:
- 路径:.
内存:512M
实例:1 个
域:mybluemix.net
名称:edge-noise-detector-bluemix
主机:edge-noise-detector-bluemix
disk_quota:1024M
buildpack:https://github.com/LeoKotschenreuther/python-tesseract-buildpack。混帐

这是我的 requirements.txt:

Flask
numpy
Pillow==4.1.1
pycparser
pyOpenSSL
pyparsing
pytesseract
python-dateutil
python-swiftclient
pytz
PyWavelets
scikit-image
scipy
requests
matplotlib==1.4.3
opencv-python
cf_deployment_tracker
tesseract

这是来自 Bluemix 的日志:

Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/app/.heroku/python/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "server.py", line 217, in predict_square_checkboxes
    ImgOcr = image_hocr_class.ocr_hocr('temporary.png')
  File "/home/vcap/app/src/image_hocr_class.py", line 39, in __init__
    self.HTMLTree = xml.etree.ElementTree.parse(self.HOCRFileName).getroot()
  File "/app/.heroku/python/lib/python3.6/xml/etree/ElementTree.py", line 1196, in parse
    tree.parse(source, parser)
  File "/app/.heroku/python/lib/python3.6/xml/etree/ElementTree.py", line 586, in parse
    source = open(source, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'images/8e297b93a39f1e08a490f72c8db53bf0.hocr'

这通常发生在 pytesseract 无法找到 tesseract 的路径时。不知道如何在 Bluemix 上完成这项工作。有没有人在 Bluemix 上使用 tesseract 获得 python?请帮忙。

4

1 回答 1

1

IBM Cloud 为您提供了多种运行应用程序的可能性。Cloud Foundry Runtimes 就是其中之一,但在您的情况下似乎不太合适。每当您需要安装依赖项时,您都需要创建自定义构建包,这可能是一项相当复杂的任务。( https://docs.cloudfoundry.org/buildpacks/custom.html ) 听说过 Docker/Kubernetes 吗?如果您有许多应用程序依赖项(例如您的情况下的 tesseract),我建议您创建一个 Kubernetes 环境来构建您的应用程序!看看这些资源:https ://hub.docker.com/r/tesseractshadow/tesseract4re/ https://console.bluemix.net/docs/containers/container_index.html#container_index

于 2017-11-15T11:30:37.890 回答