Package: mmdnn
MMdnnMMdnn 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 ConversionWe 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 RetrainingDuring the model conversion, we generate some code snippets to simplify later retraining or inference.Model Search & VisualizationWe provide amodel collectionto help you find some popular models.We provide amodel visualizerto display the network architecture more intuitively.Model DeploymentWe provide some guidelines to help you deploy DL models to another hardware platform.AndroidServingWe provide a guide to help you accelerate inference with TensorRT.TensorRTRelated ProjectsTargeting at openness and advancing state-of-art technology,Microsoft Research (MSR)andMicrosoft 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.InstallationInstall manuallyYou can get a stable version of MMdnn bypipinstallmmdnnAnd make sure to havePythoninstalled
or you can try the newest version bypipinstall-Ugit+https://github.com/Microsoft/MMdnn.git@masterInstall with docker imageMMdnn 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:Install Docker Community Edition(CE)Learn more about how to install dockerPull MMdnn docker imagedockerpullmmdnn/mmdnn:cpu.smallRun image in an interactive modedockerrun-itmmdnn/mmdnn:cpu.smallFeaturesModel ConversionAcross 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.CaffeMicrosoft Cognitive Toolkit (CNTK)CoreMLKerasMXNetONNX(Destination only)PyTorchTensorFlow(Experimental) (We highly recommend you read the README of TensorFlow first)DarkNet(Source only, Experiment)Tested modelsThe model conversion between currently supported frameworks is tested on someImageNetmodels.ModelsCaffeKerasTensorFlowCNTKMXNetPyTorchCoreMLONNXVGG 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√√√xResNext√√√√√√√√voc FCN√√Yolo3√√UsageOne command to achieve the conversion. Using TensorFlowResNet V2 152to PyTorch as our example.$mmdownload-ftensorflow-nresnet_v2_152-o./
$mmconvert-sftensorflow-inimagenet_resnet_v2_152.ckpt.meta-iwimagenet_resnet_v2_152.ckpt--dstNodeNameMMdnn_Output-dfpytorch-omtf_resnet_to_pth.pthDone.On-going frameworksTorch7 (help wanted)Chainer (help wanted)On-going ModelsFace DetectionSemantic SegmentationImage Style TransferObject DetectionRNNModel VisualizationYou can use theMMdnn model visualizerand submit your IR json file to visualize your model.  In order to run the commands below, you will need to installrequests,keras, andTensorFlowusing your favorite package manager.Use theKeras "inception_v3" modelas an example again.Download the pre-trained models$mmdownload-fkeras-ninception_v3Convert the pre-trained model files into an intermediate representation$mmtoir-fkeras-wimagenet_inception_v3.h5-okeras_inception_v3Open theMMdnn model visualizerand choose filekeras_inception_v3.jsonExamplesOfficial TutorialKeras "inception V3" to CNTKandrelated issueTensorFlow slim model "ResNet V2 152" to PyTorchMxnet model "LResNet50E-IR" to TensorFlowandrelated issueUsers' ExamplesMXNet "ResNet-152-11k" to PyTorchAnother Example of MXNet "ResNet-152-11k" to PyTorchMXNet "ResNeXt" to KerasTensorFlow "ResNet-101" to PyTorchTensorFlow "mnist mlp model" to CNTKTensorFlow "Inception_v3" to MXNetCaffe "voc-fcn" to TensorFlowCaffe "AlexNet" to TensorFlowCaffe "inception_v4" to TensorFlowCaffe "VGG16_SOD" to TensorFlowCaffe "SqueezeNet v1.1" to CNTKContributingMost 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, visithttps://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 theMicrosoft Open Source Code of Conduct.
For more information see theCode of Conduct FAQor
contactopencode@microsoft.comwith any additional questions or comments.Intermediate RepresentationThe intermediate representation stores thenetwork architectureinprotobuf binaryandpre-trained weightsinNumPynative format.[Note!] Currently the IR weights data is in NHWC (channel last) format.Details are inops.txtandgraph.proto. New operators and any comments are welcome.FrameworksWe 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 inContribution Guideline.AuthorsYu Liu (Peking University): Project Developer & MaintainerCheng CHEN (Microsoft Research Asia): Caffe, CNTK, CoreML Emitter, Keras, MXNet, TensorFlowJiahao YAO (Peking University): CoreML, MXNet Emitter, PyTorch Parser; HomePageRu ZHANG (Chinese Academy of Sciences): CoreML Emitter, DarkNet Parser, Keras, TensorFlow frozen graph Parser; Yolo and SSD models; TestsYuhao ZHOU (Shanghai Jiao Tong University): MXNetTingting QIN (Microsoft Research Asia): Caffe EmitterTong ZHAN (Microsoft): ONNX EmitterQianwen WANG (Hong Kong University of Science and Technology): VisualizationAcknowledgementsThanks toSaumitro Dasgupta, the initial code ofcaffe -> IR convertingis references to his projectcaffe-tensorflow.LicenseLicensed under theMITlicense.