Linux 下 MNN编译 | 安装 | 测试

网友投稿 1126 2022-05-29

文章目录

文档学习

首先安装 protobuf (手动源码安装)

MNN 正确编译和安装

Demo 2.1 姿态检测 ( TF 模型转换 MNN 测试 )

文档学习

系统环境: Ubuntu 18.04.5

MNN快速了解

中文文档 – https://www.yuque.com/mnn/cn/cvrt_linux_mac

首先安装 protobuf (手动源码安装)

git clone https://github.com/google/protobuf.git cd protobuf git submodule update --init --recursive ./autogen.sh ./configure 或者 指定 安装目录 (个人用户要指定到 /home/当前用户名/usr/local/ 不然下方可能会报错) ./configure --prefix=/home/moli/usr/local/ make make check make install ldconfig # refresh shared library cache.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

git submodule update --init --recursive 执行,可能遇到 benchmark.git 和 googletest.git 下载失败;

我的方法是手动下载这两个 git 库 然后 复制到 protobuf/third_party 进行解压

git submodule update --init --recursive # 报错如下 Cloning into 'third_party/benchmark'... error: RPC failed; result=52, HTTP code = 0 fatal: The remote end hung up unexpectedly Clone of 'https://github.com/google/benchmark.git' into submodule path 'third_party/benchmark' failed

1

2

3

4

5

6

7

8

./autogen.sh 执行遇到报错

./autogen.sh # 报错如下 + mkdir -p third_party/googletest/m4 + autoreconf -f -i -Wall,no-obsolete ./autogen.sh: 37: ./autogen.sh: autoreconf: not found

1

2

3

4

5

6

7

解决方法为

sudo apt-get install cmake-curses-gui sudo apt-get install autoconf automake libtool

1

2

3

4

普通用户 make install 执行遇到报错

root 权限用户应该不会遇到这个问题

libtool: error: error: cannot install 'libprotoc.la' to a directory not ending in /usr/local/lib

1

解决方法:个人用户则指定安装到 当前用户 usr/local/ 目录 下,例如

./configure --prefix=/home/moli/usr/local/

1

MNN 正确编译和安装

git clone https://github.com/alibaba/MNN.git cd MNN cd schema && ./generate.sh cd .. mkdir build && cd build cmake -DMNN_BUILD_DEMO=ON -DMNN_BUILD_CONVERTER=true .. make -j32 # 安装完成, 查看 版本 ./MNNConvert --version 0.2.1.5git

1

2

3

4

5

6

7

8

9

10

11

12

Linux 下 MNN编译 | 安装 | 测试

13

14

15

Protobuf 如果没有安装可能会遇到如下报错:

CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message): Could NOT find Protobuf (missing: Protobuf_INCLUDE_DIR) Call Stack (most recent call first): .. tools/converter/CMakeLists.txt:14 (find_package) -- Configuring incomplete, errors occurred!

1

2

3

4

5

6

7

8

9

Ubuntu 解决方法(似乎还是上面的手动源码安装能够根本解决)

sudo apt-get install libprotobuf-dev protobuf-compiler protoc --version # 输出如下 libprotoc 3.0.0

1

2

3

4

5

6

Demo 2.1 姿态检测 ( TF 模型转换 MNN 测试 )

测试主页 :https://www.yuque.com/mnn/cn/demo_project

我的转换命令如下( MNN/build 目录下 ):

./MNNConvert -f TF --modelFile ../../changeModel/model-mobilenet_v1_075.pb --MNNModel mobilenet.mnn --bizCode biz # 输出如下: MNNConverter Version: 0.2.1.5git - MNN @ 2018 Start to Convert Other Model Format To MNN Model... Start to Optimize the MNN Net... Converted Done!

1

2

3

4

5

6

7

8

9

10

选择图片进行测试

选取一张人像图像 test.png 安放在 MNN/build/test 目录下

执行命令如下:

./multiPose.out mobilenet.mnn test/test.png pose.png

1

效果如下

恭喜你已经读到文末啦,多谢你的鼓励!

Git Linux

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:H5:画布Canvas基础知识讲解(三)之文字、阴影、颜色渐变
下一篇:LabVIEW虚拟数字示波器
相关文章