3

Getting an import error with OpenVino in deployment. Have tried specifying all the previous versions of OpenVino in the requirments.txt file in case the issue has to do with versions. Exact error is:

File "/app/.heroku/python/lib/python3.8/site-packages/openvino/inference_engine/__init__.py", line 29, in <module>
2022-01-11T03:31:36.967769+00:00 app[web.1]: from .ie_api import *
2022-01-11T03:31:36.967828+00:00 app[web.1]: ImportError: /app/.heroku/python/lib/python3.8/site-packages/openvino/inference_engine/ie_api.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZTVN15InferenceEngine5TBlobIhSt9enable_ifILb1EvEEE

I'm not sure what the nature of this error is. Could it be a dependency issue? The full requirements.txt file is:

anyio
asgiref
astroid
azure-common
azure-core
azure-identity
azure-keyvault-secrets
certifi
cffi
charset-normalizer
click
cryptography
fastapi
h11
idna
isodate
isort
lazy-object-proxy
mccabe
msal
msal-extensions
msrest
oauthlib
opencv-python-inference-engine
openvino
platformdirs
portalocker
pycparser
pydantic
PyJWT
pylint
python-multipart
requests
requests-oauthlib
six
sniffio
starlette
toml
typing-extensions
urllib3
uvicorn
wrapt

There is also an Aptfile with:

libpython3.8

And the runtime.txt file contains:

python-3.8.12

In case that is of use to know. I've also tried removing Numpy from the dependencies since I heard of bugs associated with Numpy and OpenVino.

UPDATE*

Interestingly, when opencv-python-inference-engine is replaced with opencv-python-headless in requirements.txt, the error changes:

cv2.error: OpenCV(4.5.5) /io/opencv/modules/dnn/src/dnn.cpp:4319: error: (-2:Unspecified error) Build OpenCV with Inference Engine to enable loading models from Model Optimizer. in function 'readFromModelOptimizer'

So I'm thinking the error could be related to the opencv import? Or could it be related to the buildpack?

For the inference I'm using:

    im_cv = cv.imread(tmp_path_str)

    frame = cv.cvtColor(im_cv, cv.COLOR_RGB2BGR)

    blob = cv.dnn.blobFromImage(frame, size=(180,180), ddepth=cv.CV_8U)

    net.setInput(blob)

    out = net.forward()
Tekame1
  • 153
  • 4

1 Answers1

1

I encountered the same error when loading Intermediate Representation (IR) files using cv2.dnn.readNet().

Use the following command to load IR files:

from openvino.inference_engine import IECore

ie = IECore()

net = ie.read_network(“xml_file”, “bin_file”)
Rommel_Intel
  • 1,369
  • 1
  • 4
  • 8
  • Thanks so much. What do you do about inference, i.e net.setInput(blob) and the like? Also using out = net.forward(). These attributes setInput and forward don't apply anymore to the net object since loading it with ie.read_network rather than the original cv2.dnn.readNet(). Added more code to the question. Thank you as always for the suggestions. Trying to look in the docs too – Tekame1 Jan 14 '22 at 03:12
  • 1
    Ah, after your fix I solved the problem in the last comment by using ie.load_network() to create exec_net object, then used exec_net.infer! Many thanks! – Tekame1 Jan 14 '22 at 04:53