deepin-ocr/3rdparty/ncnn/python
wangzhengyang 718c41634f feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake
1.项目后端整体迁移至PaddleOCR-NCNN算法,已通过基本的兼容性测试
2.工程改为使用CMake组织,后续为了更好地兼容第三方库,不再提供QMake工程
3.重整权利声明文件,重整代码工程,确保最小化侵权风险

Log: 切换后端至PaddleOCR-NCNN,切换工程为CMake
Change-Id: I4d5d2c5d37505a4a24b389b1a4c5d12f17bfa38c
2022-05-10 10:22:11 +08:00
..
examples feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake 2022-05-10 10:22:11 +08:00
ncnn feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake 2022-05-10 10:22:11 +08:00
src feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake 2022-05-10 10:22:11 +08:00
tests feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake 2022-05-10 10:22:11 +08:00
CMakeLists.txt feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake 2022-05-10 10:22:11 +08:00
README.md feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake 2022-05-10 10:22:11 +08:00
requirements.txt feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake 2022-05-10 10:22:11 +08:00
setup.py.i feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake 2022-05-10 10:22:11 +08:00

ncnn

python wrapper of ncnn with pybind11, only support python3.x now.

Install from pip

ncnn is available as wheel packages for macOS, Windows and Linux distributions, you can install with pip:

python -m pip install -U pip
python -m pip install -U ncnn

Build from source

If you want to build ncnn with some options not as default, or just like to build everything yourself, it is not difficult to build ncnn from source.

Prerequisites

On Unix (Linux, OS X)

  • A compiler with C++11 support
  • CMake >= 3.4

On Mac

  • A compiler with C++11 support
  • CMake >= 3.4

On Windows

  • Visual Studio 2015 or higher
  • CMake >= 3.4

Build

  1. clone ncnn and init submodule.
cd /pathto/ncnn
git submodule init && git submodule update
  1. build.
mkdir build
cd build
cmake -DNCNN_PYTHON=ON ..
make

Install

cd /pathto/ncnn
pip install .

if you use conda or miniconda, you can also install as following:

cd /pathto/ncnn
python3 setup.py install

Tests

test

cd /pathto/ncnn/python
python3 tests/test.py

benchmark

cd /pathto/ncnn/python
python3 tests/benchmark.py

Numpy

ncnn.Mat->numpy.array, with no memory copy

mat = ncnn.Mat(...)
mat_np = np.array(mat)

numpy.array->ncnn.Mat, with no memory copy

mat_np = np.array(...)
mat = ncnn.Mat(mat_np)

Model Zoo

install requirements

pip install -r requirements.txt

then you can import ncnn.model_zoo and get model list as follow:

import ncnn
import ncnn.model_zoo as model_zoo

print(model_zoo.get_model_list())

models now in model zoo are as list below:

mobilenet_yolov2
mobilenetv2_yolov3
yolov4_tiny
yolov4
yolov5s
yolact
mobilenet_ssd
squeezenet_ssd
mobilenetv2_ssdlite
mobilenetv3_ssdlite
squeezenet
faster_rcnn
peleenet_ssd
retinaface
rfcn
shufflenetv2
simplepose
nanodet

all model in model zoo has example in ncnn/python/examples folder

Custom Layer

custom layer demo is in ncnn/python/ncnn/model_zoo/yolov5.py:23