【问题标题】:Python app with tesseract does not work on Bluemix带有 tesseract 的 Python 应用程序在 Bluemix 上不起作用
【发布时间】:2017-11-12 01:24:06
【问题描述】:

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

这是我的 manifest.yml:

应用:
- 路径:.
内存:512M
实例:1
域:mybluemix.net
名称:边缘噪声检测器-bluemix
主机:边缘噪声检测器-bluemix
磁盘配额:1024M
构建包:https://github.com/LeoKotschenreuther/python-tesseract-buildpack.git

这是我的 requirements.txt:

烧瓶
麻木的
枕头==4.1.1
pycparser
pyOpenSSL
pyparsing
pytesseract
python-dateutil
python-swiftclient
皮茨
PyWavelets
scikit 图像
scipy
请求
matplotlib==1.4.3
opencv-python
cf_deployment_tracker
正方体

这是来自 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?请帮忙。

【问题讨论】:

  • 错误是什么?请使用最近的日志进行编辑。
  • 我使用来自 bluemix 的服务器日志进行了更新。
  • 如果您发现 Cloud Foundry 构建包过于锁定,您可以考虑的另一种方法是在 Cloud Foundry 上创建和部署 docker 映像:ibm.com/blogs/bluemix/2017/10/…。这将使您对容器有更多的控制权。

标签: python ibm-cloud tesseract python-tesseract ibm-cloud-plugin


【解决方案1】:

IBM Cloud 为您提供了多种运行应用程序的可能性。 Cloud Foundry Runtimes 就是其中之一,但在您的情况下似乎不太合适。每当您需要安装依赖项时,您都需要创建自定义 buildpack,这可能是一项相当复杂的任务。 (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

【讨论】:

  • 谢谢 Gianluca.. 是的,我正在采用这种方法。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多