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 2.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. # ncnn
  2. python wrapper of ncnn with [pybind11](https://github.com/pybind/pybind11), only support python3.x now.
  3. Install from pip
  4. ==================
  5. ncnn is available as wheel packages for macOS, Windows and Linux distributions, you can install with pip:
  6. ```
  7. python -m pip install -U pip
  8. python -m pip install -U ncnn
  9. ```
  10. # Build from source
  11. 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.
  12. ## Prerequisites
  13. **On Unix (Linux, OS X)**
  14. * A compiler with C++11 support
  15. * CMake >= 3.4
  16. **On Mac**
  17. * A compiler with C++11 support
  18. * CMake >= 3.4
  19. **On Windows**
  20. * Visual Studio 2015 or higher
  21. * CMake >= 3.4
  22. ## Build
  23. 1. clone ncnn and init submodule.
  24. ```bash
  25. cd /pathto/ncnn
  26. git submodule init && git submodule update
  27. ```
  28. 2. build.
  29. ```bash
  30. mkdir build
  31. cd build
  32. cmake -DNCNN_PYTHON=ON ..
  33. make
  34. ```
  35. ## Install
  36. ```bash
  37. cd /pathto/ncnn
  38. pip install .
  39. ```
  40. if you use conda or miniconda, you can also install as following:
  41. ```bash
  42. cd /pathto/ncnn
  43. python3 setup.py install
  44. ```
  45. ## Tests
  46. **test**
  47. ```bash
  48. cd /pathto/ncnn/python
  49. python3 tests/test.py
  50. ```
  51. **benchmark**
  52. ```bash
  53. cd /pathto/ncnn/python
  54. python3 tests/benchmark.py
  55. ```
  56. ## Numpy
  57. **ncnn.Mat->numpy.array, with no memory copy**
  58. ```bash
  59. mat = ncnn.Mat(...)
  60. mat_np = np.array(mat)
  61. ```
  62. **numpy.array->ncnn.Mat, with no memory copy**
  63. ```bash
  64. mat_np = np.array(...)
  65. mat = ncnn.Mat(mat_np)
  66. ```
  67. # Model Zoo
  68. install requirements
  69. ```bash
  70. pip install -r requirements.txt
  71. ```
  72. then you can import ncnn.model_zoo and get model list as follow:
  73. ```bash
  74. import ncnn
  75. import ncnn.model_zoo as model_zoo
  76. print(model_zoo.get_model_list())
  77. ```
  78. models now in model zoo are as list below:
  79. ```bash
  80. mobilenet_yolov2
  81. mobilenetv2_yolov3
  82. yolov4_tiny
  83. yolov4
  84. yolov5s
  85. yolact
  86. mobilenet_ssd
  87. squeezenet_ssd
  88. mobilenetv2_ssdlite
  89. mobilenetv3_ssdlite
  90. squeezenet
  91. faster_rcnn
  92. peleenet_ssd
  93. retinaface
  94. rfcn
  95. shufflenetv2
  96. simplepose
  97. nanodet
  98. ```
  99. all model in model zoo has example in ncnn/python/examples folder
  100. # Custom Layer
  101. custom layer demo is in ncnn/python/ncnn/model_zoo/yolov5.py:23