Code Monkey home page Code Monkey logo

mnn_demos's Introduction

1. MNNDemos_Python

Python的示例

1.1 下载PyTorch GitHub模型

从PyTorch GitHub官网下载好mobilenet.py模型, pytorch 官网vision/torchvision/models/中的mobilenet.py文件。

https://github.com/pytorch/vision/tree/2ec0e847e813f6c8e060e67eb8886b4a0564c662/torchvision/models

1.2 测试mobilenet模型

python mobilenet_test.py

1.3 pytroch模型转onnx

python model2onnx.py

1.4 onnx模型转mnn,测试mnn模型

这是在conda的python环境中安装MNN。除了python能import调用API执行模型计算之外,还直接能在命令行操作MNN的工具。

pip install MNN

使用 mnnconvert -h 查看一些参数:

转换onnx模型: mnnconvert -f ONNX --modelFile mobilenet_v2-b0353104.onnx --MNNModel mobilenet_v2-b0353104.mnn --bizCode MNN

好玩的是执行python mnn_test.py遇到了错误,查阅资料发现是输入需要是NC4HW4的格式,改一下即可。

1.5 从源码编译安装MNN

pip中安装的onnx有时候转换模型并不是很好用,还是推荐从源码编译安装MNN。

mnn_demos's People

Contributors

xddun avatar

Stargazers

liang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.