当前位置:   article > 正文

腾讯神经网络推理框架NCNN试玩儿

ncnn

ncnn 是腾讯开源的神经网络推理框架,既然是一个负责推理的框架,所以不能像TF那样创建网络并且训练,它的最大用处是运行在端侧,解析并执行网络推理,输出推理结果。它可以支持各种类型的框架生成的网络。

官方仓库有详细介绍:

https://github.com/Tencent/ncnn.git

下面在普通PC的ubuntu18.04环境上搭建环境,运行一把。

1.下载代码:

git clone https://github.com/Tencent/ncnn.git

2.配置环境:

首先安装依赖:

sudo apt-get install libprotobuf-dev protobuf-compiler libopencv-dev cmake
  1. cd ncnn
  2. mkdir build
  3. cd build
  4. #cmake -DCMAKE_BUILD_TYPE=relwithdebinfo -DNCNN_OPENMP=OFF -DNCNN_THREADS=OFF -DNCNN_RUNTIME_CPU=OFF -DNCNN_RVV=ON -DNCNN_SIMPLEOCV=ON -DNCNN_BUILD_EXAMPLES=ON ..
  5. cmake ../

protobuf 为3.0.0版,可以和上面的配置对应。

3.编译

make -j4
  1. (base) caozilong@caozilong-Vostro-3268:~/Workspace/ncnn/ncnn/build$ make -j4
  2. [ 1%] Built target ncnnmerge
  3. [ 1%] Built target ncnn-generate-spirv
  4. [ 1%] Built target mxnet2ncnn
  5. [ 2%] Built target caffe2ncnn
  6. [ 2%] Built target darknet2ncnn
  7. [ 3%] Built target onnx2ncnn
  8. [ 87%] Built target ncnn
  9. [ 87%] Built target rvm
  10. [ 87%] Built target scrfd_crowdhuman
  11. [ 88%] Built target yolov4
  12. [ 88%] Built target benchncnn
  13. [ 88%] Built target simplepose
  14. [ 88%] Built target yolov3
  15. [ 89%] Built target scrfd
  16. [ 90%] Built target nanodet
  17. [ 91%] Built target shufflenetv2
  18. [ 92%] Built target squeezenet
  19. [ 92%] Built target squeezenet_c_api
  20. [ 92%] Built target yolov5
  21. [ 93%] Built target yolox
  22. [ 94%] Built target rfcn
  23. [ 95%] Built target yolov2
  24. [ 96%] Built target mobilenetv2ssdlite
  25. [ 97%] Built target squeezenetssd
  26. [ 97%] Built target mobilenetssd
  27. [ 98%] Built target peleenetssd_seg
  28. [ 99%] Built target fasterrcnn
  29. [ 99%] Built target retinaface
  30. [ 99%] Built target yolact
  31. [100%] Built target ncnn2mem
  32. [100%] Built target ncnnoptimize
  33. [100%] Built target ncnn2int8
  34. [100%] Built target ncnn2table
  35. (base) caozilong@caozilong-Vostro-3268:~/Workspace/ncnn/ncnn/build$

4.下载模型文件.

ncnn只是一个推理框架,需要吃一个训练好的算法模型文件才能正常工作,可以理解NCNN是一个模型的运行环境,所以需要准备好模型文件,NCNN官方维护了一个模型仓库,里面有常见网络算法的已经转换好的模型和权重文件。

git clone https://github.com/nihui/ncnn-assets.git

模型库中的已经转换好的模型和权重文件:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/703248
推荐阅读
相关标签
  

闽ICP备14008679号