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

Commit

Permalink
new release (#20)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
banderlog authored Apr 13, 2021
1 parent b46208d commit 5c8c5ff
Show file tree
Hide file tree
Showing 19 changed files with 267 additions and 216 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
[submodule "opencv"]
path = opencv
url = https://github.com/opencv/opencv
[submodule "openblas"]
path = openblas
url = https://github.com/xianyi/OpenBLAS
[submodule "ffmpeg"]
path = ffmpeg
url = https://github.com/FFmpeg/FFmpeg
50 changes: 14 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# opencv-python-inference-engine

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

## Installing from `pip3`

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

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

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/)
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/)


## Description


### Why

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).
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).
Well-known [opencv-python](https://github.com/skvark/opencv-python) can't do this.
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).


### Limitations

+ Package comes without contrib modules.
+ 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.
+ 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.
+ It was tested on Ubuntu 18.04, Ubuntu 18.10 as Windows 10 Subsystem and Gentoo.
+ It will not work for Ubuntu 16.04 and below (except v4.1.0.4).
+ I had not made builds for Windows or MacOS.
Expand All @@ -57,7 +57,6 @@ The official way is to use OpenVINO, but it is big and clumsy (just try to use i
### Main differences from OpenVINO

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

### Versioning

~~The first 3 letters are the version of OpenCV, underscore, then inference engine (dldt/openvino) version, underscore, package version.
E.g, `4.5.1_2120.2_0` -- first version of based on 4.5.1 OpenCV package with 2021.2 inference engine module.
Package versions are not continuously numbered -- each new OpenCV-dldt version pair starts its own numbering.~~

Above stuff is not [PEP440](https://www.python.org/dev/peps/pep-0440/) compliant. Had to switch to `YYYY.MM.DD`

`YYYY.MM.DD`, because it is the most simple way to track opencv/openvino versions.

## Compiling from source

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

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),
[ffmpeg](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu), [openBLAS](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu) and [ngraph](https://www.ngraph.ai/documentation/buildlb)

+ `build-essential`
+ `>=cmake-3.11`
+ `autoconf` (for ngraph)
+ `libtool-bin` (for ngraph)
+ `git`
+ `pkg-config`
+ `python3-dev`
+ `virtualenv`
+ `chrpath`
+ `libusb-1.0-0-dev` (for MYRIAD plugin)
+ `nasm` (for ffmpeg)
[ffmpeg](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu), and [ngraph](https://www.ngraph.ai/documentation/buildlb)

```bash
# We need newer `cmake` for dldt (fastest way I know)
# >=cmake-3.16
sudo apt remove --purge cmake
hash -r
sudo snap install cmake --classic

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

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

```bash
cd build/openblas
./openblas_setup.sh &&
make -j6 &&
make install

cd ../ffmpeg
cd build/ffmpeg
./ffmpeg_setup.sh &&
./ffmpeg_premake.sh &&
make -j6 &&
Expand Down Expand Up @@ -161,21 +141,19 @@ cp dldt/inference-engine/temp/tbb/lib/libtbb.so.2 create_wheel/cv2/

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

cp build/openblas/lib/libopenblas.so.0 create_wheel/cv2/

# change RPATH
cd create_wheel
for i in cv2/*.so; do chrpath -r '$ORIGIN' $i; done

# final .whl will be in /create_wheel/dist/
# NB: check versions in the `setup.py`
# NB: check version in the `setup.py`
../venv/bin/python3 setup.py bdist_wheel
```

### Optional things to play with

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

**NB:** removing `QUIET` from `find_package()` in project Cmake files, could help to solve some problems -- сmake will start to log them.
Expand Down
7 changes: 4 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# TODO list

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

This file was deleted.

66 changes: 27 additions & 39 deletions build/dldt/dldt_setup.sh
Original file line number Diff line number Diff line change
@@ -1,52 +1,40 @@
#!/bin/bash

# GEMM (General matrix-matrix multiplication)
#
# -D BUILD_SHARED_LIBS=ON always crash

tmp=$(pwd)
BLAS_LIB="${tmp%dldt}openblas/lib/libopenblas.so.0"
BLAS_INC="${tmp%dldt}openblas/include/openblas"

if [ ! -f $BLAS_LIB ] || [ ! -d $BLAS_INC ]; then
echo "!!! Check paths for openblas lib !!!"
echo "I tried: $BLAS_LIB and $BLAS_INC"
exit
fi

# <https://github.com/openvinotoolkit/openvino/issues/4527>
patch ../../dldt/inference-engine/cmake/dependencies.cmake dependencies.patch


# Manually-specified variables were not used by the project:
# -D ENABLE_NGRAPH=ON \
# https://github.com/openvinotoolkit/openvino/wiki/CMakeOptionsForCustomCompilation
# https://github.com/openvinotoolkit/openvino/issues/4527
# -D ENABLE_OPENCV=OFF \
# https://github.com/openvinotoolkit/openvino/issues/5100
# -D BUILD_SHARED_LIBS=OFF \
# -D BUILD_SHARED_LIBS=ON \
# https://github.com/openvinotoolkit/openvino/issues/5209
# -D NGRAPH_TOOLS_ENABLE=OFF \
cmake -D CMAKE_BUILD_TYPE=Release \
-D GEMM=OPENBLAS \
-D THREADING=TBB \
-D ENABLE_MKL_DNN=ON \
-D GEMM=JIT \
-D ENABLE_FASTER_BUILD=ON \
-D ENABLE_LTO=ON \
-D ENABLE_VPU=ON \
-D ENABLE_MYRIAD=ON \
-D ENABLE_OPENCV=ON \
-D ENABLE_MKL_DNN=ON \
-D BUILD_SHARED_LIBS=OFF \
-D BUILD_TESTS=OFF \
-D ENABLE_PYTHON=OFF \
-D ENABLE_TESTS=OFF \
-D ENABLE_SAMPLES=OFF \
-D ENABLE_GAPI_TESTS=OFF \
-D GAPI_TEST_PERF=OFF \
-D ENABLE_GNA=OFF \
-D ENABLE_PROFILING_ITT=OFF \
-D ENABLE_ALTERNATIVE_TEMP=OFF \
-D ENABLE_SSE42=ON \
-D ENABLE_AVX2=ON \
-D ENABLE_AVX512F=OFF \
-D NGRAPH_UNIT_TEST_ENABLE=OFF \
-D NGRAPH_TEST_UTIL_ENABLE=OFF \
-D NGRAPH_ONNX_IMPORT_ENABLE=ON \
-D BLAS_LIBRARIES="$BLAS_LIB" \
-D BLAS_INCLUDE_DIRS="$BLAS_INC" \
-D BUILD_TESTS=OFF \
-D ENABLE_ALTERNATIVE_TEMP=OFF \
-D ENABLE_CLDNN=OFF \
-D ENABLE_CLDNN_TESTS=OFF \
-D ENABLE_DOCS=OFF \
-D ENABLE_GAPI_TESTS=OFF \
-D ENABLE_GNA=OFF \
-D ENABLE_OPENCV=OFF \
-D ENABLE_PROFILING_ITT=OFF \
-D ENABLE_PYTHON=OFF \
-D ENABLE_SAMPLES=OFF \
-D ENABLE_SPEECH_DEMO=OFF ../../dldt/
-D ENABLE_SPEECH_DEMO=OFF \
-D ENABLE_TESTS=OFF \
-D GAPI_TEST_PERF=OFF \
-D NGRAPH_ONNX_IMPORT_ENABLE=ON \
-D NGRAPH_TEST_UTIL_ENABLE=OFF \
-D NGRAPH_TOOLS_ENABLE=OFF \
-D NGRAPH_UNIT_TEST_ENABLE=OFF \
-D SELECTIVE_BUILD=OFF ../../dldt/
5 changes: 4 additions & 1 deletion build/ffmpeg/ffmpeg_setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/bash
# deprecated: --enable-avresample , switch to libswresample
# The libswresample library performs highly optimized audio resampling,
# rematrixing and sample format conversion operations.

PATH_TO_SCRIPT=`dirname $(realpath $0)`

Expand Down Expand Up @@ -40,4 +43,4 @@ PATH_TO_SCRIPT=`dirname $(realpath $0)`
--disable-doc \
--disable-static \
--enable-pic \
--enable-shared
--enable-shared \
90 changes: 45 additions & 45 deletions build/opencv/opencv_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,61 +22,61 @@ PY_LIB_PATH=`find $ABS_PORTION/venv/lib/ -iname libpython3.${PY_VER}m.so`


cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D BUILD_DOCS=OFF \
-D BUILD_EXAMPLES=OFF \
-D BUILD_JPEG=OFF \
-D BUILD_JPEG=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_SHARED_LIBS=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_opencv_apps=OFF \
-D BUILD_opencv_java=OFF \
-D BUILD_opencv_python2.7=OFF \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=ON \
-D BUILD_opencv_world=OFF \
-D CMAKE_INSTALL_PREFIX=./binaries/ \
-D CPU_BASELINE=SSE4_2 \
-D CPU_DISPATCH=AVX,AVX2,FP16,AVX512 \
-D CV_TRACE=OFF \
-D ENABLE_CXX11=ON \
-D ENABLE_PRECOMPILED_HEADERS=OFF \
-D FFMPEG_INCLUDE_DIRS=$FFMPEG_PATH/include \
-D INF_ENGINE_INCLUDE_DIRS=$ABS_PORTION/dldt/inference-engine/include \
-D INF_ENGINE_LIB_DIRS=$ABS_PORTION/dldt/bin/intel64/Release/lib \
-D INF_ENGINE_RELEASE=2021030000 \
-D INSTALL_CREATE_DISTRIB=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D JPEG_INCLUDE_DIR=$JPEG_INCLUDE_DIR \
-D JPEG_LIBRARY=$JPEG_LIBRARY \
-D OPENCV_ENABLE_NONFREE=OFF \
-D OPENCV_FORCE_3RDPARTY_BUILD=ON \
-D OPENCV_SKIP_PYTHON_LOADER=ON \
-D BUILD_opencv_python3=ON \
-D PYTHON3_EXECUTABLE=$ABS_PORTION/venv/bin/python3 \
-D PYTHON3_LIBRARY:PATH=$PY_LIB_PATH \
-D PYTHON3_NUMPY_INCLUDE_DIRS:PATH=$ABS_PORTION/venv/lib/python3.${PY_VER}/site-packages/numpy/core/include \
-D PYTHON_DEFAULT_EXECUTABLE=$ABS_PORTION/venv/bin/python3 \
-D PYTHON3_PACKAGES_PATH=$ABS_PORTION/venv/lib/python3.${PY_VER}/site-packages \
-D PYTHON_DEFAULT_EXECUTABLE=$ABS_PORTION/venv/bin/python3 \
-D PYTHON_INCLUDE_DIR=/usr/include/python3.${PY_VER} \
-D INSTALL_CREATE_DISTRIB=ON \
-D ENABLE_CXX11=ON \
-D WITH_V4L=ON \
-D WITH_PNG=ON \
-D WITH_1394=OFF \
-D WITH_CUDA=OFF \
-D WITH_EIGEN=OFF \
-D WITH_FFMPEG=ON \
-D FFMPEG_INCLUDE_DIRS=$FFMPEG_PATH/include \
-D CMAKE_INSTALL_PREFIX=./binaries/ \
-D WITH_TBB=ON \
-D WITH_PROTOBUF=ON \
-D JPEG_INCLUDE_DIR=$JPEG_INCLUDE_DIR \
-D JPEG_LIBRARY=$JPEG_LIBRARY \
-D WITH_GSTRREAMER=OFF \
-D WITH_GTK=OFF \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python2.7=OFF \
-D BUILD_SHARED_LIBS=OFF \
-D BUILD_opencv_world=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=OFF \
-D BUILD_EXAMPLES=OFF \
-D BUILD_opencv_java=OFF \
-D BUILD_opencv_apps=OFF \
-D CV_TRACE=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_DOCS=OFF \
-D WITH_QT=OFF \
-D ENABLE_PRECOMPILED_HEADERS=OFF \
-D BUILD_JPEG=OFF \
-D WITH_INF_ENGINE=ON \
-D WITH_IPP=OFF \
-D WITH_ITT=OFF \
-D WITH_JASPER=OFF \
-D WITH_WEBP=OFF \
-D WITH_1394=OFF \
-D WITH_GSTRREAMER=OFF \
-D WITH_NGRAPH=ON \
-D WITH_OPENEXR=OFF \
-D WITH_OPENMP=OFF \
-D WITH_EIGEN=OFF \
-D WITH_PNG=ON \
-D WITH_PROTOBUF=ON \
-D WITH_QT=OFF \
-D WITH_TBB=ON \
-D WITH_V4L=ON \
-D WITH_VTK=OFF \
-D BUILD_JPEG=OFF \
-D WITH_CUDA=OFF \
-D WITH_ITT=OFF \
-D WITH_IPP=OFF \
-D WITH_NGRAPH=ON \
-D ngraph_DIR=$ABS_PORTION/build/dldt/ngraph \
-D WITH_INF_ENGINE=ON \
-D INF_ENGINE_RELEASE=2021020000 \
-D INF_ENGINE_INCLUDE_DIRS=$ABS_PORTION/dldt/inference-engine/include \
-D INF_ENGINE_LIB_DIRS=$ABS_PORTION/dldt/bin/intel64/Release/lib \
-D CPU_BASELINE=SSE4_2 \
-D CPU_DISPATCH=AVX,AVX2,FP16,AVX512 ../../opencv
-D WITH_WEBP=OFF \
-D ngraph_DIR=$ABS_PORTION/build/dldt/ngraph ../../opencv
4 changes: 2 additions & 2 deletions create_wheel/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# README

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

It built with `ffmpeg` and `v4l` but without GTK/QT (use matplotlib for plotting your results).
Contrib modules and haarcascades are not included.
Expand Down
4 changes: 2 additions & 2 deletions create_wheel/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __len__(self):

setuptools.setup(
name='opencv-python-inference-engine',
version='2021.03.03',
version='2021.04.13',
url="https://github.com/banderlog/opencv-python-inference-engine",
maintainer="Kabakov Borys",
license='MIT, Apache 2.0',
Expand All @@ -26,7 +26,7 @@ def __len__(self):
packages=['cv2'],
package_data={'cv2': ['*.so*', '*.mvcmd', '*.xml']},
include_package_data=True,
install_requires=['numpy~=1.19.2'],
install_requires=['numpy'],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
Expand Down
2 changes: 1 addition & 1 deletion dldt
Submodule dldt updated 6102 files
1 change: 0 additions & 1 deletion openblas
Submodule openblas deleted from d2b11c
2 changes: 1 addition & 1 deletion opencv
Submodule opencv updated 702 files
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
numpy==1.19.2
numpy
Loading

0 comments on commit 5c8c5ff

Please sign in to comment.