You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+132-84
Original file line number
Diff line number
Diff line change
@@ -2,30 +2,7 @@
2
2
3
3
# opencv-python-inference-engine
4
4
5
-
It is *Unofficial* pre-built OpenCV+dldt_module package for Python.
6
-
7
-
**Why:**
8
-
There is a [guy with an exellent pre-built set of OpenCV packages](https://github.com/skvark/opencv-python), but they are all came without [dldt module](https://github.com/opencv/dldt). And you need that module if you want to run models from [Intel's model zoo](https://github.com/opencv/open_model_zoo/).
9
-
10
-
**UPD:** Presumably, you could also use speech2text model now -- [source](https://docs.openvinotoolkit.org/latest/_inference_engine_samples_speech_libs_and_demos_Speech_libs_and_demos.html)
11
-
12
-
**Limitations**:
13
-
+ Package comes without contrib modules.
14
-
+ You need to [add udev rules](https://github.com/opencv/dldt/blob/2019/inference-engine/README.md#for-linux-raspbian-stretch-os) if you want working MYRIAD plugin.
15
-
+ It was tested on Ubuntu 18.04, Ubuntu 18.10 as Windows 10 Subsystem and Gentoo.
16
-
+ It will not work for Ubuntu 16.04 and below (except v4.1.0.4).
17
-
+ I had not made builds for Windows or MacOS.
18
-
+ It is 64 bit.
19
-
+ It built with `ffmpeg` and `v4l` support (`ffmpeg` libs included).
20
-
+ No GTK/QT support -- use `matplotlib` for plotting your results.
21
-
22
-
This package is most similar to `opencv-python-headless`, main differences are:
23
-
+ Usage of `AVX2` instructions
24
-
+ No `JPEG 2000`, `WEBP`, `OpenEXR` support
25
-
+`TBB` used as a parallel framework
26
-
+ Inference Engine with `MYRIAD` plugin
27
-
28
-
For additional info read `cv2.getBuildInformation()` output.
5
+
This is *Unofficial* pre-built OpenCV with the inference engine part of [dldt module](https://github.com/opencv/dldt/) package for Python.
29
6
30
7
## Installing from `pip3`
31
8
@@ -35,109 +12,109 @@ Remove previously installed versions of `cv2`
35
12
pip3 install opencv-python-inference-engine
36
13
```
37
14
38
-
## Downloading intel models
39
-
40
-
As it appeared it is not an obvious task :)
41
15
42
-
Please refer to: https://github.com/opencv/open_model_zoo/issues/522
16
+
## Why
43
17
44
-
## Known problems and TODOs
18
+
I needed an ability to fast deploy a small package that able to run models from [Intel's model zoo](https://github.com/opencv/open_model_zoo/) and use [Movidius NCS](https://software.intel.com/en-us/neural-compute-stick).
19
+
Wellr-known [opencv-python](https://github.com/skvark/opencv-python) can't do this.
20
+
The official way is to use OpenVINO, but it is big and clumsy (just try to use it with python venv or fast download it on cloud instance).
45
21
46
-
### No Ubuntu 16.04 support
47
22
48
-
Release [v4.1.0.4](https://github.com/banderlog/opencv-python-inference-engine/releases/tag/v4.1.0.4) is working with Ubuntu 16.04 ([#3](https://github.com/banderlog/opencv-python-inference-engine/issues/3)).
23
+
## Description
49
24
50
-
All releases before it were compiled on Ubuntu 18.04 and it has different versions of `glibc`, `cmake`, etc.
51
-
So make it Ubuntu 16.04 compatible was pretty easy -- just change one standard build environment to another.
25
+
### Limitations
52
26
53
-
But `dldt-2019R2` requires `cmake-3.7.2`, which is absent in Ubuntu 16.04. And, of course, it can be installed, but works-from-the-box behavior is loosed
54
-
from now on.
55
-
56
-
### No GTK/QT support
27
+
+ Package comes without contrib modules.
28
+
+ You need to [add udev rules](https://github.com/opencv/dldt/blob/2019/inference-engine/README.md#for-linux-raspbian-stretch-os) if you want working MYRIAD plugin.
29
+
+ It was tested on Ubuntu 18.04, Ubuntu 18.10 as Windows 10 Subsystem and Gentoo.
30
+
+ It will not work for Ubuntu 16.04 and below (except v4.1.0.4).
31
+
+ I had not made builds for Windows or MacOS.
32
+
+ It built with `ffmpeg` and `v4l` support (`ffmpeg` libs included).
33
+
+ No GTK/QT support -- use `matplotlib` for plotting your results.
34
+
+ It is 64 bit.
57
35
58
-
[skvarks's package](https://github.com/skvark/opencv-python) has `Qt4` GUI for `opencv` and it is +16 MB to file size.
59
-
Also it is a lot of problems and extra work to compile Qt\GTK libs from sources.
60
-
In 95% of cases `matplotlib.imshow()` will be sufficient, in other 5% use another package for now or compile it with GUI
61
-
support by yourself.
36
+
### Main differences from `opencv-python-headless`
62
37
63
-
#### Steps to compile it with `GTK-2` support (checked)
38
+
+ Usage of `AVX2` instructions
39
+
+ No `JPEG 2000`, `WEBP`, `OpenEXR` support
40
+
+`TBB` used as a parallel framework
41
+
+ Inference Engine with `MYRIAD` plugin
64
42
65
-
Make next changes in `opencv-python-inference-engine/build/opencv/opencv_setup.sh`:
66
-
1. change string `-D WITH_GTK=OFF \` to `-D WITH_GTK=ON \`
67
-
2. change `export PKG_CONFIG_PATH=$ABS_PORTION/build/ffmpeg/binaries/lib/pkgconfig:$PKG_CONFIG_PATH` -- you will need to
68
-
add absolute paths to `.pc` files. On Ubuntu 18.04 it were
Exporting `PKG_CONFIG_PATH` for `ffmpeg` somehow messes with default values.
45
+
+ No model-optimizer
46
+
+ OpenBLAS instead of MKL ([details](https://github.com/banderlog/opencv-python-inference-engine/issues))
47
+
+ No [ITT](https://software.intel.com/en-us/articles/intel-itt-api-open-source)
48
+
+ No [IPP](https://software.intel.com/en-us/ipp)
49
+
+ No [Intel Media SDK](https://software.intel.com/en-us/media-sdk)
50
+
+ No [OpenVINO IE API](https://github.com/opencv/dldt/tree/2020/inference-engine/ie_bridges/python/src/openvino/inference_engine)
51
+
+ No python2 support (it is dead)
52
+
+ No Gstreamer (use ffmpeg)
53
+
+ No GTK (+16 MB and a lot of problems and extra work to compile Qt\GTK libs from sources.)
72
54
73
-
### Not really `manylinux1`
55
+
For additional info read `cv2.getBuildInformation()` output.
74
56
75
-
The package is renamed to `manylinux1` from `linux`, because, according to [PEP 513](https://www.python.org/dev/peps/pep-0513/), PyPi repo does not want to apply other architectures.
76
-
And compiling it for CentOS 5.11 is pretty challenging (there is no such lxd container plus I do not want to mess with docker) and denies from using some of the necessary libs (like tbb).
77
-
Also, I suspect that it will be poorly optimized.
57
+
### Versioning
78
58
79
-
### Build `ffmpeg` with `tbb`
59
+
The first 3 letters are the version of OpenCV, the last one -- package version. E.g, `4.1.0.2` -- 2nd version of based on 4.1.0 OpenCV package. Package versions are not continuously numbered -- each new OpenCV version starts its own numbering.
80
60
81
-
Both `dldt` and `opencv` are compiled with `tbb` support, and `ffmpeg` compiled without it -- this does not feels right.
82
-
There is some unproved solution for how to compile `ffmpeg` with `tbb` support:
The official way is clumsy because you need to git clone the whole [model_zoo](https://github.com/opencv/open_model_zoo) ([details](https://github.com/opencv/open_model_zoo/issues/522))
89
65
90
-
First 3 letters are the version of OpenCV, the last one -- package version. E.g, `4.1.0.2` -- 2nd version of based on 4.1.0 OpenCV package. Package versions are not continuously numbered -- each new OpenCV version starts its own numbering.
66
+
Better to find a model description [here](https://github.com/opencv/open_model_zoo/blob/master/models/intel/index.md) and download manually from [here](https://download.01.org/opencv/2020/openvinotoolkit/2020.1/open_model_zoo/models_bin/1/)
91
67
92
68
93
69
## Compiling from source
94
70
95
-
I compiled it on Ubuntu 18.04 Linux Container.
71
+
You will need ~6GB RAM and ~10GB disk space
72
+
73
+
I am using Ubuntu 18.04 [multipass](https://multipass.run/) instance: `multipass launch -c 6 -d 10G -m 7G`.
(Image from [Learning OpenCV 3 by Gary Bradski, Adrian Kaehler](https://www.oreilly.com/library/view/learning-opencv-3/9781491937983/ch01.html))
172
+
173
+
[Official Intel's IPP benchmarks](https://software.intel.com/en-us/ipp/benchmarks) (may ask for registration)
174
+
175
+
#### MKL
176
+
177
+
You need to download MKL-DNN release and set two flags:`-D GEMM=MKL` , `-D MKLROOT` ([details](https://github.com/opencv/dldt/issues/327))
178
+
179
+
OpenVino comes with 30MB `libmkl_tiny_tbb.so`, but [you will not be able to compile it](https://github.com/intel/mkl-dnn/issues/674), because it made from proprietary MKL.
180
+
181
+
Our opensource MKL-DNN experiment will end with 125MB `libmklml_gnu.so` and inference speed compatible with 35MB openblas ([details](https://github.com/banderlog/opencv-python-inference-engine/issues/5)).
182
+
183
+
#### OpenBLAS
184
+
185
+
Please refer here for details: https://github.com/xianyi/OpenBLAS/issues/2528
+[OpenBLAS User Manual](https://github.com/xianyi/OpenBLAS/wiki/User-Manual)
189
+
190
+
If you compile it with `make FC=gfortran`, you'll need to put `libgfortran.so.4` and `libquadmath.so.0` to wheel and set them rpath via `patchelf --set-rpath \$ORIGIN *.so`
191
+
192
+
193
+
#### CUDA
194
+
195
+
I did not try it.
196
+
197
+
+[Compile OpenCV’s ‘dnn’ module with NVIDIA GPU support](https://www.pyimagesearch.com/2020/02/10/opencv-dnn-with-nvidia-gpus-1549-faster-yolo-ssd-and-mask-r-cnn/)
198
+
+[Use OpenCV’s ‘dnn’ module with NVIDIA GPUs, CUDA, and cuDNN](https://www.pyimagesearch.com/2020/02/03/how-to-use-opencvs-dnn-module-with-nvidia-gpus-cuda-and-cudnn/)
199
+
200
+
201
+
#### Build `ffmpeg` with `tbb`
202
+
203
+
Both `dldt` and `opencv` are compiled with `tbb` support, and `ffmpeg` compiled without it -- this does not feel right.
204
+
There is some unproved solution for how to compile `ffmpeg` with `tbb` support: <https://stackoverflow.com/questions/6049798/ffmpeg-mt-and-tbb>
205
+
206
+
207
+
#### OpenMP
208
+
209
+
It is possible to compile OpenBLAS, dldt and OpenCV with OpenMP. I am not sure that the result would be better than now, but who knows.
210
+
211
+
#### Use opencv for NLP
212
+
213
+
Presumably, you could also use speech2text model now -- [source](https://docs.openvinotoolkit.org/latest/_inference_engine_samples_speech_libs_and_demos_Speech_libs_and_demos.html)
0 commit comments