Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 5c8c5ff

Browse files
authored
new release (#20)
* pypi versioning fix * new versions * dependencies change * sha256 calculation * version bump * typo fixed * tmp * Update README.md * success with 2021.3 * test refactoring * test refactoring * numpy version upd * deprecated flags * doc refactoring * remove openblas
1 parent b46208d commit 5c8c5ff

19 files changed

+267
-216
lines changed

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
[submodule "opencv"]
55
path = opencv
66
url = https://github.com/opencv/opencv
7-
[submodule "openblas"]
8-
path = openblas
9-
url = https://github.com/xianyi/OpenBLAS
107
[submodule "ffmpeg"]
118
path = ffmpeg
129
url = https://github.com/FFmpeg/FFmpeg

README.md

+14-36
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# opencv-python-inference-engine
44

5-
This is *Unofficial* pre-built OpenCV with the inference engine part of [dldt module](https://github.com/opencv/dldt/) package for Python.
5+
This is *Unofficial* pre-built OpenCV with the inference engine part of [OpenVINO](https://github.com/openvinotoolkit/openvino) package for Python.
66

77
## Installing from `pip3`
88

@@ -23,23 +23,23 @@ You will need to preprocess data as a model requires and decode the output. A de
2323

2424
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))
2525

26-
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/)
26+
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/2021/openvinotoolkit/2021.2/open_model_zoo/models_bin/3/)
2727

2828

2929
## Description
3030

3131

3232
### Why
3333

34-
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).
34+
I needed an ability to fast deploy a small package that able to run models from [Intel's model zoo](https://github.com/openvinotoolkit/open_model_zoo) and use [Movidius NCS](https://software.intel.com/en-us/neural-compute-stick).
3535
Well-known [opencv-python](https://github.com/skvark/opencv-python) can't do this.
3636
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).
3737

3838

3939
### Limitations
4040

4141
+ Package comes without contrib modules.
42-
+ 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.
42+
+ You need to [add udev rules](https://www.intel.com/content/www/us/en/support/articles/000057005/boards-and-kits.html) if you want working MYRIAD plugin.
4343
+ It was tested on Ubuntu 18.04, Ubuntu 18.10 as Windows 10 Subsystem and Gentoo.
4444
+ It will not work for Ubuntu 16.04 and below (except v4.1.0.4).
4545
+ I had not made builds for Windows or MacOS.
@@ -57,7 +57,6 @@ The official way is to use OpenVINO, but it is big and clumsy (just try to use i
5757
### Main differences from OpenVINO
5858

5959
+ No model-optimizer
60-
+ OpenBLAS instead of MKL ([details](https://github.com/banderlog/opencv-python-inference-engine/issues/5#issuecomment-599563729))
6160
+ No [ITT](https://software.intel.com/en-us/articles/intel-itt-api-open-source)
6261
+ No [IPP](https://software.intel.com/en-us/ipp)
6362
+ No [Intel Media SDK](https://software.intel.com/en-us/media-sdk)
@@ -70,12 +69,7 @@ For additional info read `cv2.getBuildInformation()` output.
7069

7170
### Versioning
7271

73-
~~The first 3 letters are the version of OpenCV, underscore, then inference engine (dldt/openvino) version, underscore, package version.
74-
E.g, `4.5.1_2120.2_0` -- first version of based on 4.5.1 OpenCV package with 2021.2 inference engine module.
75-
Package versions are not continuously numbered -- each new OpenCV-dldt version pair starts its own numbering.~~
76-
77-
Above stuff is not [PEP440](https://www.python.org/dev/peps/pep-0440/) compliant. Had to switch to `YYYY.MM.DD`
78-
72+
`YYYY.MM.DD`, because it is the most simple way to track opencv/openvino versions.
7973

8074
## Compiling from source
8175

@@ -86,28 +80,19 @@ I am using Ubuntu 18.04 [multipass](https://multipass.run/) instance: `multipass
8680
### Requirements
8781

8882
From [opencv](https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html), [dldt](https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html),
89-
[ffmpeg](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu), [openBLAS](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu) and [ngraph](https://www.ngraph.ai/documentation/buildlb)
90-
91-
+ `build-essential`
92-
+ `>=cmake-3.11`
93-
+ `autoconf` (for ngraph)
94-
+ `libtool-bin` (for ngraph)
95-
+ `git`
96-
+ `pkg-config`
97-
+ `python3-dev`
98-
+ `virtualenv`
99-
+ `chrpath`
100-
+ `libusb-1.0-0-dev` (for MYRIAD plugin)
101-
+ `nasm` (for ffmpeg)
83+
[ffmpeg](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu), and [ngraph](https://www.ngraph.ai/documentation/buildlb)
10284

10385
```bash
10486
# We need newer `cmake` for dldt (fastest way I know)
87+
# >=cmake-3.16
10588
sudo apt remove --purge cmake
10689
hash -r
10790
sudo snap install cmake --classic
10891

10992
sudo apt-get update
110-
sudo apt install build-essential git pkg-config python3-dev nasm python3 virtualenv libusb-1.0-0-dev chrpath autoconf libtool-bin
93+
# nasm for ffmpeg
94+
# libusb-1.0-0-dev for MYRIAD plugin
95+
sudo apt install build-essential git pkg-config python3-dev nasm python3 virtualenv libusb-1.0-0-dev chrpath shellcheck
11196

11297
# for ngraph
11398
# the `dldt/_deps/ext_onnx-src/onnx/gen_proto.py` has `#!/usr/bin/env python` string and will throw an error otherwise
@@ -125,12 +110,7 @@ cd opencv-python-inference-engine
125110
### Compilation
126111

127112
```bash
128-
cd build/openblas
129-
./openblas_setup.sh &&
130-
make -j6 &&
131-
make install
132-
133-
cd ../ffmpeg
113+
cd build/ffmpeg
134114
./ffmpeg_setup.sh &&
135115
./ffmpeg_premake.sh &&
136116
make -j6 &&
@@ -161,21 +141,19 @@ cp dldt/inference-engine/temp/tbb/lib/libtbb.so.2 create_wheel/cv2/
161141

162142
cp build/ffmpeg/binaries/lib/*.so create_wheel/cv2/
163143

164-
cp build/openblas/lib/libopenblas.so.0 create_wheel/cv2/
165-
166144
# change RPATH
167145
cd create_wheel
168146
for i in cv2/*.so; do chrpath -r '$ORIGIN' $i; done
169147

170148
# final .whl will be in /create_wheel/dist/
171-
# NB: check versions in the `setup.py`
149+
# NB: check version in the `setup.py`
172150
../venv/bin/python3 setup.py bdist_wheel
173151
```
174152

175153
### Optional things to play with
176154

177-
+ [dldt build instruction](https://github.com/opencv/dldt/blob/2020/build-instruction.md)
178-
+ [dldt cmake flags](https://github.com/opencv/dldt/blob/b2140c083a068a63591e8c2e9b5f6b240790519d/inference-engine/cmake/features_ie.cmake)
155+
+ [dldt build instruction](https://github.com/openvinotoolkit/openvino/wiki/CMakeOptionsForCustomCompilation)
156+
+ [dldt cmake flags](https://github.com/openvinotoolkit/openvino/blob/master/inference-engine/cmake/features.cmake)
179157
+ [opencv cmake flags](https://github.com/opencv/opencv/blob/master/CMakeLists.txt)
180158

181159
**NB:** removing `QUIET` from `find_package()` in project Cmake files, could help to solve some problems -- сmake will start to log them.

TODO.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# TODO list
22

3-
+ dldt 2021.3 (released) + opencv 4.5.2 (waiting for release)
4-
+ get rid of tensorflow-cpu in tests
53
+ Auto value for `-D INF_ENGINE_RELEASE`: https://github.com/openvinotoolkit/openvino/issues/1435
6-
+ https://answers.opencv.org/question/236271/what-the-difference-between-cv_version_status-values/
4+
+ <https://answers.opencv.org/question/236271/what-the-difference-between-cv_version_status-values/>
5+
+ `ENABLE_AVX512F`, how often you see such CPUs in clouds?
6+
+ `avresample` from ffmpeg to the opencv, do we need it?
7+
+ results of `test_inference_engine()[::-1]`

build/dldt/dependencies.patch

-6
This file was deleted.

build/dldt/dldt_setup.sh

+27-39
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,40 @@
11
#!/bin/bash
22

3-
# GEMM (General matrix-matrix multiplication)
4-
#
5-
# -D BUILD_SHARED_LIBS=ON always crash
6-
7-
tmp=$(pwd)
8-
BLAS_LIB="${tmp%dldt}openblas/lib/libopenblas.so.0"
9-
BLAS_INC="${tmp%dldt}openblas/include/openblas"
10-
11-
if [ ! -f $BLAS_LIB ] || [ ! -d $BLAS_INC ]; then
12-
echo "!!! Check paths for openblas lib !!!"
13-
echo "I tried: $BLAS_LIB and $BLAS_INC"
14-
exit
15-
fi
16-
17-
# <https://github.com/openvinotoolkit/openvino/issues/4527>
18-
patch ../../dldt/inference-engine/cmake/dependencies.cmake dependencies.patch
19-
20-
21-
# Manually-specified variables were not used by the project:
22-
# -D ENABLE_NGRAPH=ON \
3+
# https://github.com/openvinotoolkit/openvino/wiki/CMakeOptionsForCustomCompilation
4+
# https://github.com/openvinotoolkit/openvino/issues/4527
5+
# -D ENABLE_OPENCV=OFF \
6+
# https://github.com/openvinotoolkit/openvino/issues/5100
7+
# -D BUILD_SHARED_LIBS=OFF \
8+
# -D BUILD_SHARED_LIBS=ON \
9+
# https://github.com/openvinotoolkit/openvino/issues/5209
10+
# -D NGRAPH_TOOLS_ENABLE=OFF \
2311
cmake -D CMAKE_BUILD_TYPE=Release \
24-
-D GEMM=OPENBLAS \
2512
-D THREADING=TBB \
13+
-D ENABLE_MKL_DNN=ON \
14+
-D GEMM=JIT \
15+
-D ENABLE_FASTER_BUILD=ON \
16+
-D ENABLE_LTO=ON \
2617
-D ENABLE_VPU=ON \
2718
-D ENABLE_MYRIAD=ON \
28-
-D ENABLE_OPENCV=ON \
29-
-D ENABLE_MKL_DNN=ON \
30-
-D BUILD_SHARED_LIBS=OFF \
31-
-D BUILD_TESTS=OFF \
32-
-D ENABLE_PYTHON=OFF \
33-
-D ENABLE_TESTS=OFF \
34-
-D ENABLE_SAMPLES=OFF \
35-
-D ENABLE_GAPI_TESTS=OFF \
36-
-D GAPI_TEST_PERF=OFF \
37-
-D ENABLE_GNA=OFF \
38-
-D ENABLE_PROFILING_ITT=OFF \
39-
-D ENABLE_ALTERNATIVE_TEMP=OFF \
4019
-D ENABLE_SSE42=ON \
4120
-D ENABLE_AVX2=ON \
4221
-D ENABLE_AVX512F=OFF \
43-
-D NGRAPH_UNIT_TEST_ENABLE=OFF \
44-
-D NGRAPH_TEST_UTIL_ENABLE=OFF \
45-
-D NGRAPH_ONNX_IMPORT_ENABLE=ON \
46-
-D BLAS_LIBRARIES="$BLAS_LIB" \
47-
-D BLAS_INCLUDE_DIRS="$BLAS_INC" \
22+
-D BUILD_TESTS=OFF \
23+
-D ENABLE_ALTERNATIVE_TEMP=OFF \
4824
-D ENABLE_CLDNN=OFF \
4925
-D ENABLE_CLDNN_TESTS=OFF \
26+
-D ENABLE_DOCS=OFF \
27+
-D ENABLE_GAPI_TESTS=OFF \
28+
-D ENABLE_GNA=OFF \
29+
-D ENABLE_OPENCV=OFF \
5030
-D ENABLE_PROFILING_ITT=OFF \
31+
-D ENABLE_PYTHON=OFF \
5132
-D ENABLE_SAMPLES=OFF \
52-
-D ENABLE_SPEECH_DEMO=OFF ../../dldt/
33+
-D ENABLE_SPEECH_DEMO=OFF \
34+
-D ENABLE_TESTS=OFF \
35+
-D GAPI_TEST_PERF=OFF \
36+
-D NGRAPH_ONNX_IMPORT_ENABLE=ON \
37+
-D NGRAPH_TEST_UTIL_ENABLE=OFF \
38+
-D NGRAPH_TOOLS_ENABLE=OFF \
39+
-D NGRAPH_UNIT_TEST_ENABLE=OFF \
40+
-D SELECTIVE_BUILD=OFF ../../dldt/

build/ffmpeg/ffmpeg_setup.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/bin/bash
2+
# deprecated: --enable-avresample , switch to libswresample
3+
# The libswresample library performs highly optimized audio resampling,
4+
# rematrixing and sample format conversion operations.
25

36
PATH_TO_SCRIPT=`dirname $(realpath $0)`
47

@@ -40,4 +43,4 @@ PATH_TO_SCRIPT=`dirname $(realpath $0)`
4043
--disable-doc \
4144
--disable-static \
4245
--enable-pic \
43-
--enable-shared
46+
--enable-shared \

build/opencv/opencv_setup.sh

+45-45
Original file line numberDiff line numberDiff line change
@@ -22,61 +22,61 @@ PY_LIB_PATH=`find $ABS_PORTION/venv/lib/ -iname libpython3.${PY_VER}m.so`
2222

2323

2424
cmake -D CMAKE_BUILD_TYPE=RELEASE \
25+
-D BUILD_DOCS=OFF \
26+
-D BUILD_EXAMPLES=OFF \
27+
-D BUILD_JPEG=OFF \
28+
-D BUILD_JPEG=OFF \
29+
-D BUILD_PERF_TESTS=OFF \
30+
-D BUILD_SHARED_LIBS=OFF \
31+
-D BUILD_TESTS=OFF \
32+
-D BUILD_opencv_apps=OFF \
33+
-D BUILD_opencv_java=OFF \
34+
-D BUILD_opencv_python2.7=OFF \
35+
-D BUILD_opencv_python2=OFF \
36+
-D BUILD_opencv_python3=ON \
37+
-D BUILD_opencv_world=OFF \
38+
-D CMAKE_INSTALL_PREFIX=./binaries/ \
39+
-D CPU_BASELINE=SSE4_2 \
40+
-D CPU_DISPATCH=AVX,AVX2,FP16,AVX512 \
41+
-D CV_TRACE=OFF \
42+
-D ENABLE_CXX11=ON \
43+
-D ENABLE_PRECOMPILED_HEADERS=OFF \
44+
-D FFMPEG_INCLUDE_DIRS=$FFMPEG_PATH/include \
45+
-D INF_ENGINE_INCLUDE_DIRS=$ABS_PORTION/dldt/inference-engine/include \
46+
-D INF_ENGINE_LIB_DIRS=$ABS_PORTION/dldt/bin/intel64/Release/lib \
47+
-D INF_ENGINE_RELEASE=2021030000 \
48+
-D INSTALL_CREATE_DISTRIB=ON \
49+
-D INSTALL_C_EXAMPLES=OFF \
50+
-D INSTALL_PYTHON_EXAMPLES=OFF \
51+
-D JPEG_INCLUDE_DIR=$JPEG_INCLUDE_DIR \
52+
-D JPEG_LIBRARY=$JPEG_LIBRARY \
53+
-D OPENCV_ENABLE_NONFREE=OFF \
2554
-D OPENCV_FORCE_3RDPARTY_BUILD=ON \
2655
-D OPENCV_SKIP_PYTHON_LOADER=ON \
27-
-D BUILD_opencv_python3=ON \
2856
-D PYTHON3_EXECUTABLE=$ABS_PORTION/venv/bin/python3 \
2957
-D PYTHON3_LIBRARY:PATH=$PY_LIB_PATH \
3058
-D PYTHON3_NUMPY_INCLUDE_DIRS:PATH=$ABS_PORTION/venv/lib/python3.${PY_VER}/site-packages/numpy/core/include \
31-
-D PYTHON_DEFAULT_EXECUTABLE=$ABS_PORTION/venv/bin/python3 \
3259
-D PYTHON3_PACKAGES_PATH=$ABS_PORTION/venv/lib/python3.${PY_VER}/site-packages \
60+
-D PYTHON_DEFAULT_EXECUTABLE=$ABS_PORTION/venv/bin/python3 \
3361
-D PYTHON_INCLUDE_DIR=/usr/include/python3.${PY_VER} \
34-
-D INSTALL_CREATE_DISTRIB=ON \
35-
-D ENABLE_CXX11=ON \
36-
-D WITH_V4L=ON \
37-
-D WITH_PNG=ON \
62+
-D WITH_1394=OFF \
63+
-D WITH_CUDA=OFF \
64+
-D WITH_EIGEN=OFF \
3865
-D WITH_FFMPEG=ON \
39-
-D FFMPEG_INCLUDE_DIRS=$FFMPEG_PATH/include \
40-
-D CMAKE_INSTALL_PREFIX=./binaries/ \
41-
-D WITH_TBB=ON \
42-
-D WITH_PROTOBUF=ON \
43-
-D JPEG_INCLUDE_DIR=$JPEG_INCLUDE_DIR \
44-
-D JPEG_LIBRARY=$JPEG_LIBRARY \
66+
-D WITH_GSTRREAMER=OFF \
4567
-D WITH_GTK=OFF \
46-
-D BUILD_opencv_python2=OFF \
47-
-D BUILD_opencv_python2.7=OFF \
48-
-D BUILD_SHARED_LIBS=OFF \
49-
-D BUILD_opencv_world=OFF \
50-
-D INSTALL_PYTHON_EXAMPLES=OFF \
51-
-D INSTALL_C_EXAMPLES=OFF \
52-
-D OPENCV_ENABLE_NONFREE=OFF \
53-
-D BUILD_EXAMPLES=OFF \
54-
-D BUILD_opencv_java=OFF \
55-
-D BUILD_opencv_apps=OFF \
56-
-D CV_TRACE=OFF \
57-
-D BUILD_TESTS=OFF \
58-
-D BUILD_PERF_TESTS=OFF \
59-
-D BUILD_DOCS=OFF \
60-
-D WITH_QT=OFF \
61-
-D ENABLE_PRECOMPILED_HEADERS=OFF \
62-
-D BUILD_JPEG=OFF \
68+
-D WITH_INF_ENGINE=ON \
69+
-D WITH_IPP=OFF \
70+
-D WITH_ITT=OFF \
6371
-D WITH_JASPER=OFF \
64-
-D WITH_WEBP=OFF \
65-
-D WITH_1394=OFF \
66-
-D WITH_GSTRREAMER=OFF \
72+
-D WITH_NGRAPH=ON \
6773
-D WITH_OPENEXR=OFF \
6874
-D WITH_OPENMP=OFF \
69-
-D WITH_EIGEN=OFF \
75+
-D WITH_PNG=ON \
76+
-D WITH_PROTOBUF=ON \
77+
-D WITH_QT=OFF \
78+
-D WITH_TBB=ON \
79+
-D WITH_V4L=ON \
7080
-D WITH_VTK=OFF \
71-
-D BUILD_JPEG=OFF \
72-
-D WITH_CUDA=OFF \
73-
-D WITH_ITT=OFF \
74-
-D WITH_IPP=OFF \
75-
-D WITH_NGRAPH=ON \
76-
-D ngraph_DIR=$ABS_PORTION/build/dldt/ngraph \
77-
-D WITH_INF_ENGINE=ON \
78-
-D INF_ENGINE_RELEASE=2021020000 \
79-
-D INF_ENGINE_INCLUDE_DIRS=$ABS_PORTION/dldt/inference-engine/include \
80-
-D INF_ENGINE_LIB_DIRS=$ABS_PORTION/dldt/bin/intel64/Release/lib \
81-
-D CPU_BASELINE=SSE4_2 \
82-
-D CPU_DISPATCH=AVX,AVX2,FP16,AVX512 ../../opencv
81+
-D WITH_WEBP=OFF \
82+
-D ngraph_DIR=$ABS_PORTION/build/dldt/ngraph ../../opencv

create_wheel/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# README
22

3-
This is a pre-built [OpenCV](https://github.com/opencv/opencv) with [dldt](https://github.com/opencv/dldt) module package for Python3.
4-
You need that module if you want to run models from [Intel's model zoo](https://github.com/opencv/open_model_zoo/).
3+
This is a pre-built [OpenCV](https://github.com/opencv/opencv) with [Inference Engine](https://github.com/openvinotoolkit/openvino) module package for Python3.
4+
You need that module if you want to run models from [Intel's model zoo](https://github.com/openvinotoolkit/open_model_zoo).
55

66
It built with `ffmpeg` and `v4l` but without GTK/QT (use matplotlib for plotting your results).
77
Contrib modules and haarcascades are not included.

create_wheel/setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def __len__(self):
1515

1616
setuptools.setup(
1717
name='opencv-python-inference-engine',
18-
version='2021.03.03',
18+
version='2021.04.13',
1919
url="https://github.com/banderlog/opencv-python-inference-engine",
2020
maintainer="Kabakov Borys",
2121
license='MIT, Apache 2.0',
@@ -26,7 +26,7 @@ def __len__(self):
2626
packages=['cv2'],
2727
package_data={'cv2': ['*.so*', '*.mvcmd', '*.xml']},
2828
include_package_data=True,
29-
install_requires=['numpy~=1.19.2'],
29+
install_requires=['numpy'],
3030
classifiers=[
3131
'Development Status :: 5 - Production/Stable',
3232
'Environment :: Console',

dldt

Submodule dldt updated 6102 files

openblas

-1
This file was deleted.

opencv

Submodule opencv updated 702 files

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
numpy==1.19.2
1+
numpy

0 commit comments

Comments
 (0)