python wrapper of ncnn with pybind11, only support python3.x now.
On Unix (Linux, OS X)
On Windows
cd /pathto/ncnn
git submodule init && git submodule update
mkdir build
cd build
cmake -DNCNN_BUILD_PYTHON=ON ..
make
cd /pathto/ncnn/python
pip install .
if you use conda or miniconda, you can also install as following:
cd /pathto/ncnn/python
python3 setup.py install
test
cd /pathto/ncnn/python
python3 tests/test.py
benchmark
cd /pathto/ncnn/python
python3 tests/benchmark.py
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)
install requirements
pip install -U 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())
all model in model zoo has example in ncnn/python/examples folder
custom layer demo is in ncnn/python/ncnn/model_zoo/yolov5.py:23