MMdnn

microsoftMIT长期未更新

在不同深度学习框架之间转换模型并可视化网络结构,支持 Caffe、Keras、MXNet、TensorFlow、PyTorch、ONNX、CoreML 等格式互转。

MMdnn is a set of tools to help users inter-operate among different deep learning frameworks. E.g. model conversion and visualization. Convert models between Caffe, Keras, MXNet, Tensorflow, CNTK, PyTorch Onnx and CoreML.

0.3.1发布于 2020-07-24 06:14 UTC5,803star951fork同步于 2026-11-10 05:34 UTC

怎么上手

由 README 提炼,执行前请确认
pip install mmdnn
硬件要求按 README 说明

README 未说明具体硬件要求;提供 CPU 版 Docker 镜像 mmdnn/mmdnn:cpu.small,可在无 GPU 环境试用

有 Docker 镜像
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

微软开源的跨框架模型转换与可视化工具,让模型能在不同深度学习框架间迁移部署

在不同深度学习框架之间转换模型并可视化网络结构,支持 Caffe、Keras、MXNet、TensorFlow、PyTorch、ONNX、CoreML 等格式互转。

核心能力

  • 通过中间表示格式在框架间转换模型
  • 支持 Caffe、Keras、MXNet、TensorFlow、CNTK、PyTorch、CoreML 等
  • 转换时生成代码片段便于后续重训练或推理
  • 提供本地可视化工具展示网络结构
  • 附带模型库和 Android、TensorRT 部署指南

容易踩的坑

TensorFlow 支持标注为 Experimental,建议先读对应 README;ONNX 仅支持作为转换目标,DarkNet 仅支持作为来源;转换前需先用 mmdownload 下载对应框架的预训练模型

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本0.3.1
  1. 0.3.1MMdnn 0.3.1 Release最新正式版2020-07-24 · 2020-07-24 06:14 UTC

    Initial support for PyTorch1.5.1 .

  2. 0.3.0MMdnn 0.3.0 Release2020-05-03 · 2020-05-03 05:48 UTC
    查看更新说明

    Updated dependencies:

    • NumPy 1.15.4 =>1.18.2
    • Pillow 5.2.0=>6.2.2
    • TensorFlow 1.13.1 =>1.15.2
    • Keras 2.2.4 =>2.2.5
    • MXNet 1.2.0 =>1.6.0
    • CNTK 2.6 =>2.7
    • SciPy==1.4.1
    • Scikit-image==0.16.2

    Bug Fixed and Improvement:

    • Fix op [LRN]
    • Fix tensorflow_parser[Slice], [DepthwiseConv2dNative]
    • Fix caffe_emitter[Relu6]
    • Add op [Unpool]
    • Add keras [Affine]
    • Add tensorflow [AddV2], [FusedBatchNormV3]
    • Stability improvements.

    Tips:

    We recommand Python 3.6 since Python 2 has retired. If you experience incompatibility with other Python 3.x versions, please submit an issue.

  3. 0.2.5Update Some Packages2019-04-15 · 2019-04-15 05:23 UTC
    查看更新说明

    Updated dependencies:

    Numpy 1.14.5 => 1.15.4
    Tensorflow 1.9.0 => 1.13.1
    Keras 2.1.6=>2.2.4
    CoreML 0.8=> 2.1.0
    Cntk 2.5.1=>2.6
    MXNet 1.1.0 post0 => 1.2.0
    Onnx 1.2.1=>1.4.1
    Onnx-tf =>1.2.1(python3), 1.1.2(python2)
    

    Bug Fixes and Improvements:

    • Fix Caffe constant emit
    • Add visual studio solution file
    • Add pytorch_emit [Prelu]
    • Add tf_parser & pytorch_emit [Cast]
    • Add keras_parser [Conv1DTranspose], [Conv2DTranspose], [Conv3DTranspose]
  4. 0.2.4Initial support for RNN operators2019-03-03 · 2019-03-03 15:21 UTC
    查看更新说明
    1. Initial implementation for RNN operators including GRU (Gated Recurrent Unit) cell, LSTM (Long Short-Term Memory) cell (no support for peephole yet) by matching the cell's corresponding pattern and fold them into a fuction or class in target framework.

    2. Various fixes and stability improvements.

  5. 0.2.3Support Paddle Parser2019-03-03 · 2019-03-03 15:21 UTC
    查看更新说明

    ir

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    MMdnn MMdnn

    PyPi Version License Linux

    MMdnn is a comprehensive and cross-framework tool to convert, visualize and diagnose deep learning (DL) models. The "MM" stands for model management, and "dnn" is the acronym of deep neural network.

    Major features include:

    • Model Conversion

      • We implement a universal converter to convert DL models between frameworks, which means you can train a model with one framework and deploy it with another.
    • Model Retraining

      • During the model conversion, we generate some code snippets to simplify later retraining or inference.
    • Model Search & Visualization

      • We provide a model collection to help you find some popular models.
      • We provide a model visualizer to display the network architecture more intuitively.
    • Model Deployment

      • We provide some guidelines to help you deploy DL models to another hardware platform.

      • We provide a guide to help you accelerate inference with TensorRT.

    Related Projects

    Targeting at openness and advancing state-of-art technology, Microsoft Research (MSR) and Microsoft Software Technology Center (STC) had also released few other open source projects:

    • OpenPAI : an open source platform that provides complete AI model training and resource management capabilities, it is easy to extend and supports on-premise, cloud and hybrid environments in various scale.
    • FrameworkController : an open source general-purpose Kubernetes Pod Controller that orchestrate all kinds of applications on Kubernetes by a single controller.
    • NNI : a lightweight but powerful toolkit to help users automate Feature Engineering, Neural Architecture Search, Hyperparameter Tuning and Model Compression.
    • NeuronBlocks : an NLP deep learning modeling toolkit that helps engineers to build DNN models like playing Lego. The main goal of this toolkit is to minimize developing cost for NLP deep neural network model building, including both training and inference stages.
    • SPTAG : Space Partition Tree And Graph (SPTAG) is an open source library for large scale vector approximate nearest neighbor search scenario.

    We encourage researchers, developers and students to leverage these projects to boost their AI / Deep Learning productivity.

    Installation

    Install manually

    You can get a stable version of MMdnn by

    pip install mmdnn
    

    And make sure to have Python installed or you can try the newest version by

    pip install -U git+https://github.com/Microsoft/MMdnn.git@master
    

    Install with docker image

    MMdnn provides a docker image, which packages MMdnn and Deep Learning frameworks that we support as well as other dependencies. You can easily try the image with the following steps:

    1. Install Docker Community Edition(CE)

      Learn more about how to install docker

    2. Pull MMdnn docker image

      docker pull mmdnn/mmdnn:cpu.small
      
    3. Run image in an interactive mode

      docker run -it mmdnn/mmdnn:cpu.small
      

    Features

    Model Conversion

    Across the industry and academia, there are a number of existing frameworks available for developers and researchers to design a model, where each framework has its own network structure definition and saving model format. The gaps between frameworks impede the inter-operation of the models.

    We provide a model converter to help developers convert models between frameworks through an intermediate representation format.

    Support frameworks

    [Note] You can click the links to get detailed README of each framework.

    Tested models

    The model conversion between currently supported frameworks is tested on some ImageNet models.

    ModelsCaffeKerasTensorFlowCNTKMXNetPyTorchCoreMLONNX
    VGG 19√√√√√√√√
    Inception V1√√√√√√√√
    Inception V3√√√√√√√√
    Inception V4√√√o√√√√
    ResNet V1×√√o√√√√
    ResNet V2√√√√√√√√
    MobileNet V1×√√o√√√√
    MobileNet V2×√√o√√√√
    Xception√√√o×√√√
    SqueezeNet√√√√√√√√
    DenseNet√√√√√√√√
    NASNetx√√o√√√x
    ResNext√√√√√√√√
    voc FCN√√
    Yolo3√√
    Usage

    One command to achieve the conversion. Using TensorFlow ResNet V2 152 to PyTorch as our example.

    $ mmdownload -f tensorflow -n resnet_v2_152 -o ./
    $ mmconvert -sf tensorflow -in imagenet_resnet_v2_152.ckpt.meta -iw imagenet_resnet_v2_152.ckpt --dstNodeName MMdnn_Output -df pytorch -om tf_resnet_to_pth.pth
    

    Done.

    On-going frameworks
    • Torch7 (help wanted)
    • Chainer (help wanted)
    On-going Models
    • Face Detection
    • Semantic Segmentation
    • Image Style Transfer
    • Object Detection
    • RNN

    Model Visualization

    We provide a local visualizer to display the network architecture of a deep learning model. Please refer to the instruction.


    Examples

    Official Tutorial

    Users' Examples


    Contributing

    Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

    When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

    This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

    Intermediate Representation

    The intermediate representation stores the network architecture in protobuf binary and pre-trained weights in NumPy native format.

    [Note!] Currently the IR weights data is in NHWC (channel last) format.

    Details are in ops.txt and graph.proto. New operators and any comments are welcome.

    Frameworks

    We are working on other frameworks conversion and visualization, such as PyTorch, CoreML and so on. We're investigating more RNN related operators. Any contributions and suggestions are welcome! Details in Contribution Guideline.

    Authors

    Yu Liu (Peking University): Project Developer & Maintainer

    Cheng CHEN (Microsoft Research Asia): Caffe, CNTK, CoreML Emitter, Keras, MXNet, TensorFlow

    Jiahao YAO (Peking University): CoreML, MXNet Emitter, PyTorch Parser; HomePage

    Ru ZHANG (Chinese Academy of Sciences): CoreML Emitter, DarkNet Parser, Keras, TensorFlow frozen graph Parser; Yolo and SSD models; Tests

    Yuhao ZHOU (Shanghai Jiao Tong University): MXNet

    Tingting QIN (Microsoft Research Asia): Caffe Emitter

    Tong ZHAN (Microsoft): ONNX Emitter

    Qianwen WANG (Hong Kong University of Science and Technology): Visualization

    Acknowledgements

    Thanks to Saumitro Dasgupta, the initial code of caffe -> IR converting is references to his project caffe-tensorflow.

    License

    Licensed under the MIT license.