python wrapper of ncnn with pybind11, only support python3.x now.
On Unix (Linux, OS X)
- A compiler with C++11 support
- CMake >= 3.4
On Windows
- Visual Studio 2015
- CMake >= 3.4
- clone ncnn and pybind11, build and install with default setting, if you change the install directory, change the cmake commond with your setting.
cd /path/to/pyncnn
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=/path/to/ncnn/build/install/lib/cmake/ncnn/ ..
make
cd /path/to/pyncnn/python
pip install .
if you use conda or miniconda, you can also install as following:
cd /path/to/pyncnn/python
python3 setup.py install
test
cd /path/to/pyncnn/tests
python3 test.py
benchmark
cd /path/to/pyncnn/tests
python3 benchmark.py
benchmark gpu(build ncnn with vulkan)
cd /path/to/pyncnn/tests
python3 benchmark_gpu.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 tqdm requests portalocker opencv-python
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 examples folder