admin管理员组

文章数量:1530059

                           MNN+win10模型转换工具编译

MNN的说明文档叫做语雀,链接https://www.yuque/mnn

MNN模型转换工具win10编译教程:https://www.yuque/mnn/cn/ko86hi

但是实际操作按照教程可能不太容易通过编译,作者没有给出很多需要注意的细节。在这里给出一个详细的step by step教程,确保windows用户能够顺利编译通过。

一、准备工作:

1、 .ps1文件是PowerShell写好的脚本文件。在Windows系统中,默认情况下是不允许执行.ps1文件的。需要 执行如下命令,降低系统的安全性,允许执行脚本:set-executionpolicy -executionpolicy unrestricted,具体做法:C:\Windows\System32\WindowsPowerShell\v1.0目录下以管理员权限打开powershell.exe,然后执行set-executionpolicy -executionpolicy unrestricted,提示选Y

2、https://github/google/flatbuffers/releases 下载flatc.exe 并将其放到your_path/MNN/3rd_party/flatbuffers/tmp 目录下。这样可以防止执行.ps1时报:无法将“../../3rd_party/flatbuffers/tmp/flatc.exe”项识别为cmdlet、函数、脚本文件或可运行程序的名称。

3、下载protobuf,(文档中给出的下载地址https://github/protocolbuffers/protobuf),编译之:

1git clone  https://github/protocolbuffers/protobuf

2)  cd protobuf 然后执行git submodule update --init –recursive

3)在protobuf目录下mkdir vsprojects

4) cd vsprojects 并执行

cmake -G "Visual Studio 16 2019" -Dprotobuf_BUILD_TESTS=OFF ../cmake

5)打开该目录下生成sln,选择为x64 Release模式并编译之。

运行vs工程下的extract_includes.bat就能生成protobuf的头文件,如下图所示

6)配置环境变量这个很简单,直接将Release目录和include目录配置到环境变量即可。

二、编译

       准备工作做好了,现在可以编译了,教程中这样说:cd /path/to/MNN/tools/converter

并且./build_tool.ps1,如果在控制台下面,是无法执行的。按照教程无法成功。

  1. 管理员身份打开powershell.exeC:\Windows\System32\WindowsPowerShell\v1.0\

  cd /path/to/MNN/tools/converter,执行generate_schema.ps1,很顺利,

   2、继续执行./ build_tool.ps1,报错如下,这个是执行脚本无法找到nmake.

打开build_tool.ps1文件可以看到

这个时候我们手动编译,以管理员身份打开vs2019的命令行

cd /path/to/MNN/tools/converter目录下,mkdir build然后cd build,接着执行

cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release ..

nmake

不出意外编译成功!!!Good Luck !!!

 

 

 

 

 

本文标签: 转换工具模型MNN