Tengine 树莓派 安装及使用

依赖安装

sudo apt-get install libprotobuf-dev
sudo apt-get install protobuf-compiler
sudo apt-get install libboost-all-dev
sudo apt-get install libgoogle-glog-dev
sudo apt-get install libopencv-dev
sudo apt-get install libopenblas-dev

如果有些包在树莓派上使用apt-get安装不了,改用aptitude安装

下载编译

git clone https://github.com/OAID/Tengine.git
cd Tengine/
cp makefile.config.example makefile.config

编辑makefile.config:

  1. 将CONFIG_ARCH_ARM64=y 注释掉
  2. 将CONFIG_ARCH_ARM32=y 取消注释 (新发布的版本必须要这么做,否者编译后不产生libhclcpu.so libtengine.so文件)
  3. 将CONFIG_ARCH_BLAS=y 取消注释

make -j4
make install
(编译大概需要25分钟)

编译测试mobileSSD

  1. 下载mobilessd模型,并放在Tengine/models下
    https://download.csdn.net/download/huxiny/11824964

  2. 编译mobile_ssd例子:

cd ~/Tengine/examples/mobilenet_ssd 
cmake –DTENGINE_DIR=/home/pi/Tengine .
make

如果make 出现下面错误:

/home/pi/husin/Tengine/examples/mobilenet_ssd/mssd.cpp:32:27: fatal error: tengine_c_api.h: No such file or directory
 #include "tengine_c_api.h"
                           ^
compilation terminated.
CMakeFiles/MSSD.dir/build.make:62: recipe for target 'CMakeFiles/MSSD.dir/mssd.cpp.o' failed
make[2]: *** [CMakeFiles/MSSD.dir/mssd.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/MSSD.dir/all' failed
make[1]: *** [CMakeFiles/MSSD.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

该问题产生的原因是 -DTENGINE_DIR 指定 Tengine 的安装路径。

则需要先make clean,并且删除cmake产生的文件
修改CMAKE文件:
(加入一行)

cmake_minimum_required (VERSION 2.8)
project(MSSD)
add_definitions(-std=c++11)

# TODO:设置 TENGINE_DIR 的路径
set( TENGINE_DIR /home/hxy/tengine )

set( INSTALL_DIR ${TENGINE_DIR}/install/)
set( TENGINE_LIBS tengine)

就可以正常编译了。

./MSSD

proto file not specified,using /home/pi/husin/Tengine/models/MobileNetSSD_deploy.prototxt by default
model file not specified,using /home/pi/husin/Tengine/models/MobileNetSSD_deploy.caffemodel by default
image file not specified,using /home/pi/husin/Tengine/tests/images/ssd_dog.jpg by default
--------------------------------------
repeat 1 times, avg time per run is 1821.49 ms
detect result num: 3 
dog	:100%
BOX:( 138.509 , 209.394 ),( 324.57 , 541.314 )
car	:100%
BOX:( 467.315 , 72.8045 ),( 687.269 , 171.128 )
bicycle	:100%
BOX:( 107.395 , 140.657 ),( 574.212 , 415.188 )
======================================
[DETECTED IMAGE SAVED]:	save.jpg
======================================

参考文章

http://shumeipai.nxez.com/2018/12/07/tengine-inference-engine-raspberry-pi-deep-learning.html
https://www.jianshu.com/p/d2ed2c77efd3 (Tengine mobile_ssd 代码分析)

发布了61 篇原创文章 · 获赞 44 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/HUXINY/article/details/101273578