You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.4 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # ncnn
  2. python wrapper of ncnn with [pybind11](https://github.com/pybind/pybind11), only support python3.x now.
  3. ## Prerequisites
  4. **On Unix (Linux, OS X)**
  5. * A compiler with C++11 support
  6. * CMake >= 3.4
  7. **On Windows**
  8. * Visual Studio 2015 or higher
  9. * CMake >= 3.4
  10. ## Build
  11. 1. clone ncnn and init submodule.
  12. ```bash
  13. cd /pathto/ncnn
  14. git submodule init && git submodule update
  15. ```
  16. 2. build.
  17. ```bash
  18. mkdir build
  19. cd build
  20. cmake -DNCNN_BUILD_PYTHON=ON ..
  21. make
  22. ```
  23. ## Install
  24. ```bash
  25. cd /pathto/ncnn/python
  26. pip install .
  27. ```
  28. if you use conda or miniconda, you can also install as following:
  29. ```bash
  30. cd /pathto/ncnn/python
  31. python3 setup.py install
  32. ```
  33. ## Tests
  34. **test**
  35. ```bash
  36. cd /pathto/ncnn/python
  37. python3 tests/test.py
  38. ```
  39. **benchmark**
  40. ```bash
  41. cd /pathto/ncnn/python
  42. python3 tests/benchmark.py
  43. ```
  44. ## Numpy
  45. **ncnn.Mat->numpy.array, with no memory copy**
  46. ```bash
  47. mat = ncnn.Mat(...)
  48. mat_np = np.array(mat)
  49. ```
  50. **numpy.array->ncnn.Mat, with no memory copy**
  51. ```bash
  52. mat_np = np.array(...)
  53. mat = ncnn.Mat(mat_np)
  54. ```
  55. # Model Zoo
  56. install requirements
  57. ```bash
  58. pip install -U requirements.txt
  59. ```
  60. then you can import ncnn.model_zoo and get model list as follow:
  61. ```bash
  62. import ncnn
  63. import ncnn.model_zoo as model_zoo
  64. print(model_zoo.get_model_list())
  65. ```
  66. all model in model zoo has example in ncnn/python/examples folder
  67. # Custom Layer
  68. custom layer demo is in ncnn/python/ncnn/model_zoo/yolov5.py:23