I'm trying to do inference with OpenVino Model Optimizer as detailed here.
The code I have so far runs without installing cv2, but I can't get any further because trying to import cv2 consistently throws an error. The code is:
import openvino
from openvino.inference_engine import IECore, IENetwork
import cv2
ie = IECore()
net = ie.read_network(model='saved_model.xml', weights='saved_model.bin')
This runs without
import cv2
However, anytime the cv2 import is included the following error is thrown:
File "/opt/intel/openvino_2021/python/python3.9/cv2/__init__.py", line 129, in <module>
bootstrap()
File "/opt/intel/openvino_2021/python/python3.9/cv2/__init__.py", line 112, in bootstrap
import cv2
ImportError: dlopen(/opt/intel/openvino_2021.4.752/python/python3.9/cv2/python-3/cv2.so, 2): Symbol not found: _objc_alloc_init
Referenced from: /opt/intel/openvino_2021.4.752/python/python3.9/cv2/python-3/../../../../opencv/lib/libopencv_videoio.4.5.dylib (which was built for Mac OS X 10.15)
Expected in: /usr/lib/libobjc.A.dylib
in /opt/intel/openvino_2021.4.752/python/python3.9/cv2/python-3/../../../../opencv/lib/libopencv_videoio.4.5.dylib
I've tried downgrading cv2 to various previous versions but this did not seem to help. cv2 is needed for the cv2.dnn.blobFromImage method which I'm trying to use in this script.
Has anyone seen this problem before? Not sure how to interpret this error message.
Refer to Install and Configure Intel® Distribution of OpenVINO™ toolkit for macOS, the Intel® Distribution of OpenVINO™ version 2021.4.2 is supported on macOS version 10.15 and Python version 3.6 – 3.8.
Please ensure your Operating System is macOS 10.15 and Python version within 3.6 to 3.8.
Related
I am using python 3.8, spaCy 3.2.4, tensorflow 2.8.0, cuda 11.2, tensorflow-gpu 2.8.0. I want to import spacy, but it shows this error
import spacy
Process finished with exit code -1073740791 (0xC0000409)
Then, to fix this issue, I have to use this code
import tensorflow
import spacy
Now, it works. Although I already fixed the issue, I still want to know the reason behind the solution.
Furthermore, another question is when typing
import spacy
It shows:
Backend QtAgg is interactive backend. Turning interactive mode on.
How to always choose Qt5Agg or TkAgg instead of QtAgg? How to always turn on the interactive mode? I am using PyCharm IDE Community Edition 2020.3.5.
I am having trouble with a Jupyter script that I am using for a class at university. Useful information: I am using a MacBook Air (first time), macOS Monterey 12.0.1, M1 Apple chip, and I am working in a conda virtual environment with conda 4.11.0 and Python 3.9.7. This is the first part of the script:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from tensorflow import keras <--
import tensorflow as tf <--
from sklearn.utils import shuffle
from sklearn import preprocessing
from keras import regularizers <--
import random
from keras.utils.vis_utils import plot_model <--
import time
from IPython.display import Image
When I run it, I get this message:
The kernel appears to have died. It will restart automatically.
I tried commenting each row, and apparently, the problem is due to the ones that I highlighted with the arrow. So there is something wrong with TensorFlow. As suggested by my professor, I went on the terminal, typed ipython, then this:
In [1]: import tensorflow
zsh: illegal hardware instruction ipython
I looked it up on the internet, and I understood that there are some incompatibilities between some Python packages and the M1 Apple chip. I tried to follow this https://github.com/apple/tensorflow_macos, but when I use the command written there, this is what happens
(phdcourse) alessandroruggieri#Alessandros-MacBook-Air ~ % /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/apple/tensorflow_macos/master/scripts/download_and_install.sh)"
ERROR: TensorFlow with ML Compute acceleration is only available on macOS 11.0 and later.
This is pretty weird, considering I have macOS 12.0.1 (as said at the beginning).
To conclude, I have seen some posts about similar issues on the internet, but they all look rather confusing, so I would really appreciate an easy and clear help.
I work on the python code in VS Code for image processing and i need to use tensorflow. When I want to import tensorflow i get this error:
import tensorflow as tf
E0401:Unable to import 'tensorflow'
I have read ImportError: No module named tensorflow for Visual Studio Code but it is used for working with GPU but I only want to work with CPU.
How can I fix it?
Thanks in advance.
You should create an environment for your python project.
After that, you should install tensorflow with pip.
Using Python 2.7 (miniconda) and trying to run below example, but it is said Unresolved reference to example_parser_configuration_pb2, does anyone have any solutions?
BTW, my machine is configured with tensorflow and I can run some tensorflow examples, so tensorflow basic configuration should be ok.
from tensorflow.core.example import example_parser_configuration_pb2
https://github.com/tensorflow/tensorflow/blob/754048a0453a04a761e112ae5d99c149eb9910dd/tensorflow/python/util/example_parser_configuration_test.py#L70
regards,
Lin
I'm trying to use scikit-learn's neural network module in iPython... running Python 3.5 on a Win10, 64-bit machine.
When I try to import from sknn.mlp import Classifier, Layer , I get back the following AttributeError: module 'theano' has no attribute 'gof' ...
The command line highlighted for the error is class DisconnectedType(theano.gof.type.Type), within theano\gradient.py
Theano version is 0.8.2, everything installed via pip.
Any lights on what may be causing this and how to fix it?
Apparently it was caused by some issue with Visual Studio. The import worked when I reinstalled VS and restarted the computer.
Thanks #super_cr7 for the prompt reply!