Code Monkey home page Code Monkey logo

microsoft / mmdnn Goto Github PK

View Code? Open in Web Editor NEW
5.8K 182.0 968.0 36.34 MB

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.

License: MIT License

Python 94.72% JavaScript 2.30% HTML 0.27% TypeScript 1.86% CSS 0.77% Shell 0.07%
cntk visualization tensorflow model-converter pytorch caffe keras mxnet coreml onnx

mmdnn's Introduction

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

  • 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

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.

Models Caffe Keras TensorFlow CNTK MXNet PyTorch CoreML ONNX
VGG 19
Inception V1
Inception V3
Inception V4 o
ResNet V1 × o
ResNet V2
MobileNet V1 × o
MobileNet V2 × o
Xception o ×
SqueezeNet
DenseNet
NASNet x 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

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.

mmdnn's People

Contributors

2h4dl avatar 2yz avatar abonas avatar bharathgs avatar chenghaz avatar galli-leo avatar gzuidhof avatar jiahaoyao avatar kingofthebongo2008 avatar kitstar avatar liangfu avatar linmajia avatar luuil avatar microsoftopensource avatar namizzz avatar rainliuplus avatar scarlett2018 avatar sebastieneske avatar shumatsu avatar skybigzhou avatar smokerx avatar tengerye avatar tobeyqin avatar trishitapingolia avatar vbe0201 avatar wagamama avatar wangqianwen0418 avatar xiaoxye avatar zhangsodagreen avatar zhantong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mmdnn's Issues

Error in conversion of Inception Model from Keras to CNTK

Hi kitstar,

I have saved Inception Model and its Weights using the below code:

import numpy as np
import tensorflow as tf
import os
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
from keras.layers import Dropout, Flatten, Dense
from keras import applications

BackEndModel = applications.InceptionV3(include_top=False, weights='imagenet')
model_json = BackEndModel.to_json()
with open("incpetionTopModel.json", "w") as json_file:
json_file.write(model_json)
BackEndModel.save_weights("incpetionTopModel.h5")

Now, I want to convert this model and weight files to cntk. Using the standard procedure as mentioned in mmdnn documentation, I am getting the following error in the last step (After generating the CNTK code snippet, you can convert the code and IR weights file to CNTK original model). Following is the error trace:

(C:\Program Files\Anaconda3\envs\py35) >python -m mmdnn.conversion.examples.cntk.imagenet_test
-n cntkInceptionTopModel.py -w IRIncpetionTopModel.npy --dump cntkInceptionTopMo
del.dnn
Selected CPU as the process wide default device.
C:\Program Files\Anaconda3\envs\py35\lib\site-packages\cntk\core.py:82: RuntimeW
arning: data is not C contiguous; rearrange your data/computation to avoid costl
y data conversions
RuntimeWarning)
Traceback (most recent call last):
File "C:\Program Files\Anaconda3\envs\py35\lib\runpy.py", line 184, in _run_mo
dule_as_main
"main", mod_spec)
File "C:\Program Files\Anaconda3\envs\py35\lib\runpy.py", line 85, in run_cod
e
exec(code, run_globals)
File "C:\Program Files\Anaconda3\envs\py35\lib\site-packages\mmdnn\conversion
examples\cntk\imagenet_test.py", line 57, in
tester = TestCNTK()
File "C:\Program Files\Anaconda3\envs\py35\lib\site-packages\mmdnn\conversion
examples\cntk\imagenet_test.py", line 22, in init
self.model = self.MainModel.KitModel(self.args.w)
File "D:\Rishi\Machine Learning\CNTK\MMdnn-master\mmdnn\conversion\cntk\cntkIn
ceptionTopModel.py", line 27, in KitModel
conv2d_189 = convolution(input_3, strides = (2, 2,), auto_padding = [Fa
lse, False, False], name = 'conv2d_189')
File "D:\Rishi\Machine Learning\CNTK\MMdnn-master\mmdnn\conversion\cntk\cntkIn
ceptionTopModel.py", line 374, in convolution
input = cntk.transpose(input, [dim - 2] + list(range(0, dim - 2)))
File "C:\Program Files\Anaconda3\envs\py35\lib\site-packages\cntk\internal\swi
g_helper.py", line 69, in wrapper
result = f(*args, **kwds)
File "C:\Program Files\Anaconda3\envs\py35\lib\site-packages\cntk\ops_init

.py", line 2056, in transpose
return transpose(x, perm, name)
RuntimeError: invalid vector subscript

Kindly help me out with it.
I have already added -node add as suggested by you while generating IRCode from Keras Model.

AttributeError: 'InputLayer' object has no attribute 'inbound_nodes'

I followed https://github.com/Microsoft/MMdnn/blob/master/docs/keras2cntk.md to convert Keras "inception_v3" to CNTK. when I tried to run the second step
python -m mmdnn.conversion._script.convertToIR -f keras -d converted -n imagenet_inception_v3.json -w imagenet_inception_v3.h5
I got this error
/home/nghia/.local/lib/python2.7/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from floattonp.floatingis deprecated. In future, it will be treated asnp.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters Using TensorFlow backend. 2018-01-17 16:21:50.244399: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA 2018-01-17 16:21:50.298185: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:892] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero 2018-01-17 16:21:50.298543: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties: name: GeForce GTX 660 major: 3 minor: 0 memoryClockRate(GHz): 0.8885 pciBusID: 0000:01:00.0 totalMemory: 1.45GiB freeMemory: 1.08GiB 2018-01-17 16:21:50.298561: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 660, pci bus id: 0000:01:00.0, compute capability: 3.0) Network file [imagenet_inception_v3.json] and [imagenet_inception_v3.h5] is loaded successfully. Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/home/nghia/.local/lib/python2.7/site-packages/mmdnn/conversion/_script/convertToIR.py", line 164, in <module> _main() File "/home/nghia/.local/lib/python2.7/site-packages/mmdnn/conversion/_script/convertToIR.py", line 159, in _main ret = _convert(args) File "/home/nghia/.local/lib/python2.7/site-packages/mmdnn/conversion/_script/convertToIR.py", line 63, in _convert parser = Keras2Parser(model) File "/home/nghia/.local/lib/python2.7/site-packages/mmdnn/conversion/keras/keras2_parser.py", line 101, in __init__ self.keras_graph.build() File "/home/nghia/.local/lib/python2.7/site-packages/mmdnn/conversion/keras/keras2_graph.py", line 47, in build for node in layer.inbound_nodes: AttributeError: 'InputLayer' object has no attribute 'inbound_nodes'
any suggestion?

Can't predict with converted model (Tensorflow -> MxNet)

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

pip list:
mxnet (0.11.0)
tensorflow (1.4.0)

I have model is trained by Tensorflow, based on Inception V3.
After convert Tensorflow to IR and convert IR to MXNET, But I can't predict image with converted model.

``
def predict(model, filename):
print filename
array = loadImage(filename)
Batch = namedtuple('Batch', ['data'])
mod.forward(Batch([array]), is_train=True)
pred = mod.get_outputs()[0].asnumpy()
return pred

def loadModel():
inception_v3, arg_params, aux_params = mx.model.load_checkpoint("inception_v3", 0)
mod = mx.mod.Module(symbol=inception_v3, data_names=('input',))
mod.bind(for_training=False, data_shapes=[('input', (1,3,299,299))])
mod.set_params(arg_params, aux_params)
return mod
``

The below is error log
_Traceback (most recent call last):
File "/Users/tung1404/Downloads/_pc_vision/sample_mxnet/workspace/01_acr/test_converted_model.py", line 42, in
print predict(mod, file)
File "/Users/tung1404/Downloads/_pc_vision/sample_mxnet/workspace/01_acr/test_converted_model.py", line 20, in predict
mod.forward(Batch([array]), is_train=True)
File "/Users/tung1404/Downloads/_pc_vision/sample_mxnet/lib/python2.7/site-packages/mxnet/module/module.py", line 594, in forward
self.reshape(new_dshape, new_lshape)
File "/Users/tung1404/Downloads/_pc_vision/sample_mxnet/lib/python2.7/site-packages/mxnet/module/module.py", line 459, in reshape
self._exec_group.reshape(self._data_shapes, self._label_shapes)
File "/Users/tung1404/Downloads/_pc_vision/sample_mxnet/lib/python2.7/site-packages/mxnet/module/executor_group.py", line 348, in reshape
self.bind_exec(data_shapes, label_shapes, reshape=True)
File "/Users/tung1404/Downloads/_pc_vision/sample_mxnet/lib/python2.7/site-packages/mxnet/module/executor_group.py", line 324, in bind_exec
allow_up_sizing=True, **dict(data_shapes_i + label_shapes_i))
File "/Users/tung1404/Downloads/_pc_vision/sample_mxnet/lib/python2.7/site-packages/mxnet/executor.py", line 399, in reshape
arg_shapes, _, aux_shapes = self._symbol.infer_shape(**kwargs)
File "/Users/tung1404/Downloads/_pc_vision/sample_mxnet/lib/python2.7/site-packages/mxnet/symbol.py", line 978, in infer_shape
res = self._infer_shape_impl(False, *args, **kwargs)
File "/Users/tung1404/Downloads/_pc_vision/sample_mxnet/lib/python2.7/site-packages/mxnet/symbol.py", line 1107, in _infer_shape_impl
ctypes.byref(complete)))
File "/Users/tung1404/Downloads/pc_vision/sample_mxnet/lib/python2.7/site-packages/mxnet/base.py", line 129, in check_call
raise MXNetError(py_str(LIB.MXGetLastError()))
mxnet.base.MXNetError: Error in operator InceptionV3/InceptionV3/Conv2d_2a_3x3/Conv2D: [17:49:38] src/operator/./convolution-inl.h:463: Check failed: dilated_ksize_x <= AddPad(dshape[3], param
.pad[1]) (3 vs. 1) kernel size exceed input

[Group conv support] ValueError: number of input channels does not match corresponding dimension of filter, 96 != 48

Hi,

I converted BVLC_AlexNet from Caffe to IR first. Then converted IR to Tensorflow code snippet in order to use it to get the checkpoint file. But when I tried to test my converted model by executing python -m mmdnn.conversion.examples.tensorflow.imagenet_test -s tensorflow -p AlexNet -n BVLC_AlexNet -w BVLC_AlexNet.npy, the error happened below:

Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/examples/tensorflow/imagenet_test.py", line 68, in <module>
    tester = TestTF()
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/examples/tensorflow/imagenet_test.py", line 17, in __init__
    self.input, self.model = self.MainModel.KitModel(self.args.w)
  File "BVLC_AlexNet.py", line 33, in KitModel
    conv2_1         = convolution(conv2_0, strides = [1, 1], padding = 'VALID', name = 'conv2_1')
  File "BVLC_AlexNet.py", line 62, in convolution
    layer = tf.nn.convolution(input, w, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.py", line 750, in convolution
    name=name, data_format=data_format)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.py", line 807, in __init__
    num_spatial_dims]))
ValueError: number of input channels does not match corresponding dimension of filter, 96 != 48

If you wanna take a look at my converted model, here is the link
Can you please deal with it?
Thanks.

TensorflowEmitter has not supported operator [batch_normalization].

This happened to me when converting a Caffe classification model using batch norm to TensorFlow. I used Python 3 and MMdnn-0.1.1, installed via pip.

Should be fixed by changing mmdnn/conversion/caffe/mapper.py:193 from
return Node.create('batch_normalization', **kwargs) to
return Node.create('BatchNorm', **kwargs).

stable version didn't work well

Hi,
Below is my repo. I'm trying to use MMdnn to convert model from Keras to Tensorflow, and very glad you provide such a excellent tool to use.
https://github.com/purelyvivid/MMdnn-util
The problem is that when I used the, said, "stable version", it didn't work well. I got wrong massages like "inbound layer" when I tried to convert model structure to IR. Then I installed the newest version and problem solved.
Will you provide or update the stable version that can work really well? Thanks!

Platform (like ubuntu 16.04/win10): ubuntu 16.04

Python version: 2.7

Source framework with version (like Tensorflow 1.4.1 with GPU):Tensorflow 1.4 with GPU

Destination framework with version (like CNTK 2.3 with GPU):

Pre-trained model path (webpath or webdisk path):

Running scripts:

[Slice of Caffe parser support] Error when converting DPN68 from caffe to IR

Hi,

This is my model: link

The error message showed up when I tried to convert my model from caffe to IR:

Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 159, in <module>
    _main()
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 154, in _main
    ret = _convert(args)
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 9, in _convert
    transformer = CaffeTransformer(args.network, args.weights, "tensorflow", args.inputShape, phase = args.caffePhase)
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/caffe/transformer.py", line 308, in __init__
    graph = GraphBuilder(def_path, self.input_shape, self.is_train_proto, phase).build()
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/caffe/graph.py", line 444, in build
    graph.compute_output_shapes(self.model)
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/caffe/graph.py", line 265, in compute_output_shapes
    node.output_shape = TensorShape(*NodeKind.compute_output_shape(node))
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/caffe/graph.py", line 127, in compute_output_shape
    raise ConversionError('Output shape computation not implemented for type: %s' % node.kind)
mmdnn.conversion.caffe.errors.ConversionError: Output shape computation not implemented for type: Slice

Can you check this out?

Thank you

ImportError: No module named contrib.keras.python.keras.preprocessing

I've install the MMdnn by executing this command pip install https://github.com/Microsoft/MMdnn/releases/download/0.1.0/mmdnn-0.1.0-py2.py3-none-any.whl
And I've done these

$ wget http://download.tensorflow.org/models/resnet_v2_152_2017_04_14.tar.gz -P examples/tf/
$ tar -xvf examples/tf/inception_v3_2016_08_28.tar.gz
$ rm examples/tf/inception_v3_2016_08_28.tar.gz
$ mv *.ckpt *.graph examples/tf/

But the following error happened when I tried to run python -m mmdnn.conversion.examples.tensorflow.extract_model -n resnet152 -ckpt examples/tf/resnet_v2_152.ckpt

Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/parallels/Desktop/CarML/MMdnn/mmdnn/conversion/examples/tensorflow/extract_model.py", line 12, in <module>
    from mmdnn.conversion.examples.imagenet_test import TestKit
  File "mmdnn/conversion/examples/imagenet_test.py", line 11, in <module>
    from tensorflow.contrib.keras.python.keras.preprocessing import image
ImportError: No module named contrib.keras.python.keras.preprocessing

Can you help me dealing with this? Thank you.

[Group convolution in Keras] ResNeXt mxnet -> IR -> keras

Hi
Thank you for a great covert tool.

I am trying to convert from mxnet resnext to keras.
symbol file: http://data.mxnet.io/models/imagenet/resnext/101-layers/resnext-101-64x4d-symbol.json
param file: http://data.mxnet.io/models/imagenet/resnext/101-layers/resnext-101-64x4d-0000.params

I could convert from mxnet to IR with no error,

python -m mmdnn.conversion._script.convertToIR -f mxnet -n resnext-101-64x4d-symbol.json -w resnext-101-64x4d-0000.params -d resnext-101-64x4d --inputShape 3 224 224

but failed to convert from IR to keras with an error below.
Would you support this model?

Regards,


python -m mmdnn.conversion._script.IRToCode -f keras --IRModelPath resnext-101-64x4d.pb --dstModelPath keras_resnext-101-64x4d.py

Parse file [resnext-101-64x4d.pb] with binary format successfully.
Traceback (most recent call last):
File "C:\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "C:\Anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Anaconda3\lib\site-packages\mmdnn\conversion_script\IRToCode.py", line 120, in
_main()
File "C:\Anaconda3\lib\site-packages\mmdnn\conversion_script\IRToCode.py", line 115, in _main
ret = _convert(args)
File "C:\Anaconda3\lib\site-packages\mmdnn\conversion_script\IRToCode.py", line 56, in _convert
emitter.run(args.dstModelPath, args.dstWeightPath, args.phase)
File "C:\Anaconda3\lib\site-packages\mmdnn\conversion\common\DataStructure\emitter.py", line 21, in run
self.save_code(dstNetworkPath, phase)
File "C:\Anaconda3\lib\site-packages\mmdnn\conversion\common\DataStructure\emitter.py", line 53, in save_code
code = self.gen_code(phase)
File "C:\Anaconda3\lib\site-packages\mmdnn\conversion\keras\keras2_emitter.py", line 95, in gen_code
func(current_node)
File "C:\Anaconda3\lib\site-packages\mmdnn\conversion\keras\keras2_emitter.py", line 194, in emit_Conv
return self._emit_convolution(IR_node, 'layers.Conv{}D'.format(dim))
File "C:\Anaconda3\lib\site-packages\mmdnn\conversion\keras\keras2_emitter.py", line 179, in _emit_convolution
input_node, padding = self._defuse_padding(IR_node)
File "C:\Anaconda3\lib\site-packages\mmdnn\conversion\keras\keras2_emitter.py", line 160, in _defuse_padding
padding = self._convert_padding(padding)
File "C:\Anaconda3\lib\site-packages\mmdnn\conversion\keras\keras2_emitter.py", line 139, in _convert_padding
padding = convert_onnx_pad_to_tf(padding)[1:-1]
File "C:\Anaconda3\lib\site-packages\mmdnn\conversion\common\utils.py", line 62, in convert_onnx_pad_to_tf
return np.transpose(np.array(pads).reshape([2, -1])).reshape(-1, 2).tolist()

ValueError: cannot reshape array of size 1 into shape (2,newaxis)

Cannot convert caffe model with "Reshape" layer

When the deploy.prototxt file contains layer of type "Reshape", convertToIR script crashes with error:

Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 159, in <module>
    _main()
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 154, in _main
    ret = _convert(args)
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 9, in _convert
    transformer = CaffeTransformer(args.network, args.weights, "tensorflow", args.inputShape, phase = args.caffePhase)
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/caffe/transformer.py", line 308, in __init__
    graph = GraphBuilder(def_path, self.input_shape, self.is_train_proto, phase).build()
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/caffe/graph.py", line 444, in build
    graph.compute_output_shapes(self.model)
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/caffe/graph.py", line 265, in compute_output_shapes
    node.output_shape = TensorShape(*NodeKind.compute_output_shape(node))
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/caffe/graph.py", line 125, in compute_output_shape
    return LAYER_DESCRIPTORS[node.kind](node)
KeyError: None

[GAN support] how to convert from tensorflow to keras

Thank you for a great covert tool!
I want to convert tensorflow model to keras model.
However, the following error occurred.

Platform:ubuntu 16.04
Python version:2.7.12
Source framework with version :Tensorflow 1.3.0 with GPU
Destination framework with version :keras with 2.1.3
Pre-trained model path :https://drive.google.com/open?id=1KNOH5OtPLHQyod02A3L9_xJVWE5pdmcf
code : https://github.com/xhujoy/CycleGAN-tensorflow

Running scripts:

$python -m mmdnn.conversion._script.convertToIR -f tensorflow -d isCycle -n cyclegan.model-213002.meta --dstNodeName generatorA2B/g_pred_c/Conv/weights -w cyclegan.model-213002.index

Parse file [cyclegan.model-213002.meta] with binary format successfully.
Tensorflow model file [cyclegan.model-213002.meta] loaded successfully.
Tensorflow checkpoint file [cyclegan.model-213002.index] loaded successfully. [0] variables loaded.
IR network structure is saved as [isCycle.json].
IR network structure is saved as [isCycle.pb].
IR weights are saved as [isCycle.npy].

$python -m mmdnn.conversion._script.IRToCode -f keras --IRModelPath isCycle.pb --dstModelPath convertedCycle.py --IRWeightPath isCycle.npy

Parse file [isCycle.pb] with binary format successfully.
Target network code snippet is saved as [convertedCycle.py].

$python -m mmdnn.conversion.examples.keras.imagenet_test -n convertedCycle.py -w isCycle.npy --dump cyclegan.h5

/usr/local/lib/python2.7/dist-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
Using TensorFlow backend.
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/examples/keras/imagenet_test.py", line 58, in <module>
    tester.dump()
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/examples/keras/imagenet_test.py", line 50, in dump
    self.model.save(path)
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 2573, in save
    save_model(self, filepath, overwrite, include_optimizer)
  File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 115, in save_model
    if legacy_models.needs_legacy_support(model):
  File "/usr/local/lib/python2.7/dist-packages/keras/legacy/models.py", line 9, in needs_legacy_support
    return isinstance(model.layers[0], Merge)
IndexError: list index out of range

can not convert Resnet101-Faster-Rcnn from tensorflow to IR then to MXNET

I am not sure whether it is possible to convert Resnet101-Faster-Rcnn from tensorflow to IR then to MXNET. I can not even pass convert from Resnet101 to IR. Thank you so much

Platform (like ubuntu 16.04/win10):
ubuntu

Source framework with version (like Tensorflow 1.4.1 with GPU):
Tensorflow with GPU

Pre-trained model path (webpath or webdisk path): Path is:
https://drive.google.com/drive/folders/0B1_fAEgxdnvJeGg0LWJZZ1N2aDA
name: coco_900-1190k.tgz

Running scripts:
For second step:
python -m mmdnn.conversion.examples.tensorflow.extract_model -n resnet50 -ckpt examples/tf/res50_faster_rcnn_iter_1190000.ckpt.data-00000-of-00001

bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
2018-02-07 23:26:33.110263: W tensorflow/core/util/tensor_slice_reader.cc:95] Could not open examples/tf/res50_faster_rcnn_iter_1190000.ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
2018-02-07 23:26:33.111700: W tensorflow/core/util/tensor_slice_reader.cc:95] Could not open examples/tf/res50_faster_rcnn_iter_1190000.ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
2018-02-07 23:26:33.111733: W tensorflow/core/framework/op_kernel.cc:1192] Data loss: Unable to open table file examples/tf/res50_faster_rcnn_iter_1190000.ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
2018-02-07 23:26:33.111703: W tensorflow/core/util/tensor_slice_reader.cc:95] Could not open examples/tf/res50_faster_rcnn_iter_1190000.ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
2018-02-07 23:26:33.116709: W tensorflow/core/util/tensor_slice_reader.cc:95] Could not open examples/tf/res50_faster_rcnn_iter_1190000.ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
2018-02-07 23:26:33.116975: W tensorflow/core/framework/op_kernel.cc:1192] Data loss: Unable to open table file examples/tf/res50_faster_rcnn_iter_1190000.ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
2018-02-07 23:26:33.117285: W tensorflow/core/util/tensor_slice_reader.cc:95] Could not open examples/tf/res50_faster_rcnn_iter_1190000.ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
2018-02-07 23:26:33.118989: W tensorflow/core/util/tensor_slice_reader.cc:95] Could not open examples/tf/res50_faster_rcnn_iter_1190000.ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
2018-02-07 23:26:33.118992: W tensorflow/core/util/tensor_slice_reader.cc:95] Could not open examples/tf/res50_faster_rcnn_iter_1190000.ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
2018-02-07 23:26:33.119025: W tensorflow/core/framework/op_kernel.cc:1192] Data loss: Unable to open table file examples/tf/res50_faster_rcnn_iter_1190000.ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
2018-02-07 23:26:33.126774: W tensorflow/core/util/tensor_slice_reader.cc:95] Could not open examples/tf/res50_faster_rcnn_iter_1190000.ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
2018-02-07 23:26:33.126781: W tensorflow/core/util/tensor_slice_reader.cc:95] Could not open examples/tf/res50_faster_rcnn_iter_1190000.ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
2018-02-07 23:26:33.127091: W tensorflow/core/framework/op_kernel.cc:1192] Data loss: Unable to open table file examples/tf/res50_faster_rcnn_iter_1190000.ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
2018-02-07 23:26:33.128075: W tensorflow/core/util/tensor_slice_reader.cc:95] Could not open examples/tf/res50_faster_rcnn_iter_1190000.ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
2018-02-07 23:26:33.128339: W tensorflow/core/framework/op_kernel.cc:1192] Data loss: Unable to open table file examples/tf/res50_faster_rcnn_iter_1190000.ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/xuw080/tensorflow/lib/python2.7/site-packages/mmdnn/conversion/examples/tensorflow/extract_model.py", line 103, in
_main()
File "/home/xuw080/tensorflow/lib/python2.7/site-packages/mmdnn/conversion/examples/tensorflow/extract_model.py", line 86, in _main
saver.restore(sess, args.checkpoint)
File "/home/xuw080/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1666, in restore
{self.saver_def.filename_tensor_name: save_path})
File "/home/xuw080/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 889, in run
run_metadata_ptr)
File "/home/xuw080/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1120, in _run
feed_dict_tensor, options, run_metadata)
File "/home/xuw080/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1317, in _do_run
options, run_metadata)
File "/home/xuw080/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1336, in _do_call
raise type(e)(node_def, op, message)

Caused by op u'save/RestoreV2_126', defined at:
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/xuw080/tensorflow/lib/python2.7/site-packages/mmdnn/conversion/examples/tensorflow/extract_model.py", line 103, in
_main()
File "/home/xuw080/tensorflow/lib/python2.7/site-packages/mmdnn/conversion/examples/tensorflow/extract_model.py", line 85, in _main
saver = tf.train.Saver()
File "/home/xuw080/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1218, in init
self.build()
File "/home/xuw080/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1227, in build
self._build(self._filename, build_save=True, build_restore=True)
File "/home/xuw080/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1263, in _build
build_save=build_save, build_restore=build_restore)
File "/home/xuw080/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 751, in _build_internal
restore_sequentially, reshape)
File "/home/xuw080/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 427, in _AddRestoreOps
tensors = self.restore_op(filename_tensor, saveable, preferred_shard)
File "/home/xuw080/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 267, in restore_op
[spec.tensor.dtype])[0])
File "/home/xuw080/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_io_ops.py", line 1021, in restore_v2
shape_and_slices=shape_and_slices, dtypes=dtypes, name=name)
File "/home/xuw080/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/home/xuw080/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2956, in create_op
op_def=op_def)
File "/home/xuw080/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1470, in init
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

DataLossError (see above for traceback): Unable to open table file examples/tf/res50_faster_rcnn_iter_1190000.ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
[[Node: save/RestoreV2_126 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2_126/tensor_names, save/RestoreV2_126/shape_and_slices)]]
[[Node: save/RestoreV2_263/_37 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_584_save/RestoreV2_263", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"]]

Keras --> IR --> pyTorch error ['PytorchEmitter' has no attribute 'body_codes']

When I convert my Keras (TF) model to IR then attempt to convert to pyTorch I get this error:
AttributeError: 'PytorchEmitter' object has no attribute 'body_codes'

Here's the code:

from mmdnn.conversion.keras.keras2_parser import Keras2Parser

parser = Keras2Parser(('cnn_structure.json', 'cnn_weights.h5'))   

parser.gen_IR()
parser.save_to_json("ir_model.json")
parser.save_to_proto("ir_model.pb")
parser.save_weights("ir_model.npy")

from mmdnn.conversion.pytorch.pytorch_emitter import PytorchEmitter
emitter = PytorchEmitter(('ir_model.pb', 'ir_model.npy')) 
emitter.run('converted_pytorch_model', 'converted_pytorch_weights', 'test')

Here is the full error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-6-5319026321ce> in <module>()
      1 from mmdnn.conversion.pytorch.pytorch_emitter import PytorchEmitter
      2 emitter = PytorchEmitter(('ir_model.pb', 'ir_model.npy'))
----> 3 emitter.run('converted_pytorch_model', 'converted_pytorch_weights', 'test')

/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/pytorch/pytorch_emitter.pyc in run(self, dstNetworkPath, dstWeightPath, phase)
     42 
     43     def run(self, dstNetworkPath, dstWeightPath = None, phase = 'test'):
---> 44         super(PytorchEmitter, self).run(dstNetworkPath, dstWeightPath, phase)
     45         if self.weight_loaded:
     46             self.save_weights(self.weights_dict, dstWeightPath)

/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/common/DataStructure/emitter.pyc in run(self, dstNetworkPath, dstWeightPath, phase)
     19 
     20     def run(self, dstNetworkPath, dstWeightPath = None, phase = 'test'):
---> 21         self.save_code(dstNetworkPath, phase)
     22 
     23 

/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/common/DataStructure/emitter.pyc in save_code(self, filepath, phase)
     51 
     52     def save_code(self, filepath, phase):
---> 53         code = self.gen_code(phase)
     54         with open(filepath, 'w') as fout:
     55             fout.write(code)

/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/pytorch/pytorch_emitter.pyc in gen_code(self, phase)
    107             func()
    108 
--> 109         return self.header_code + '\n' + self.init_code + '\n' + self.body_codes
    110 
    111 

AttributeError: 'PytorchEmitter' object has no attribute 'body_codes'

Problem converting Tensorflow (mobilenet model) to IR

I'm attempting to convert a TF model (mobilenet) to IR.

Looking at the model in Tensorboard tells me that the output node is called output (see screencap).

However, when I run the conversion with the arguments:

python -m mmdnn.conversion._script.convertToIR -f tensorflow -d mobilenet_v1_1/0_224 -n /hdd/mobilenet/00-conversions/mobilenet_v1_1.0_224.ckpt.meta -w /hdd/mobilenet/00-conversions/mobilenet_v1_1.0_224.ckpt --dstNodeName output

I get the error

...
AssertionError: output is not in graph

I'm pretty sure that the output node is called output in this model. Is there any glaring mistakes I've made?

MXNet convertorToIR don't parse 'attrs' layer parameters

Platform: Ununtu 16.04

Python version: 3.6

Source framework with version: MXNet 1.0.0 with GPU

Destination framework with version: TensorFlow 1.4.1 with GPU

Pre-trained model path: LResNet50E-IR

Model json-file contain layers in the following form:
{ "op": "Convolution", "name": "conv0", "attrs": { "kernel": "(3, 3)", "no_bias": "True", "num_filter": "64", "pad": "(1, 1)", "stride": "(1, 1)", "workspace": "256" }, "inputs": [[3, 0, 0], [4, 0, 0]] }

Running scripts:
python -m mmdnn.conversion._script.convertToIR -f mxnet -n model-symbol.json -w model-0000.params -d model-descr512 --inputShape 3 112 112

Error:

Traceback (most recent call last):
  File "/opt/anaconda3/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/opt/anaconda3/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/opt/anaconda3/lib/python3.6/site-packages/mmdnn/conversion/_script/convertToIR.py", line 140, in <module>
    _main()
  File "/opt/anaconda3/lib/python3.6/site-packages/mmdnn/conversion/_script/convertToIR.py", line 135, in _main
    ret = _convert(args)
  File "/opt/anaconda3/lib/python3.6/site-packages/mmdnn/conversion/_script/convertToIR.py", line 72, in _convert
    parser.run(args.dstPath)
  File "/opt/anaconda3/lib/python3.6/site-packages/mmdnn/conversion/common/DataStructure/parser.py", line 22, in run
    self.gen_IR()
  File "/opt/anaconda3/lib/python3.6/site-packages/mmdnn/conversion/mxnet/mxnet_parser.py", line 266, in gen_IR
    func(current_node)
  File "/opt/anaconda3/lib/python3.6/site-packages/mmdnn/conversion/mxnet/mxnet_parser.py", line 457, in rename_Convolution
    assert "attr" in source_node.layer or "param" in source_node.layer
AssertionError

[MXNet SSD model support] Problem in converting ssd inception model from mxnet to IR.

Platform (like ubuntu 16.04):

Python version: 2.7.12

Source framework with version: MXNET 1.0.0 with GPU

Destination framework with version: Tensorflow 1.4.1 with GPU

I was able to convert InceptionV3 (mxnet) to IR but I encounter a problem when I try to convert ssd InceptionV3 model(mxnet).

Running scripts:
root@2f2520263ec5:/home/bomo/Desktop# python -m mmdnn.conversion._script.convertToIR -f mxnet -n ssd_inceptionv3_512-symbol.json -d ssd_inceptionv3_512 --inputShape 3 512 512

error:
[14:37:20] src/nnvm/legacy_json_util.cc:209: Loading symbol saved by previous version v0.12.0. Attempting to upgrade... [14:37:20] src/nnvm/legacy_json_util.cc:217: Symbol successfully upgraded! /mxnet/python/mxnet/module/base_module.py:53: UserWarning: You created Module with Module(..., label_names=['softmax_label']) but input with name 'softmax_label' is not found in symbol.list_arguments(). Did you mean one of: data label warnings.warn(msg) Warning: MXNet Parser has not supported operator null with name data. Warning: convert the null operator with name [data] into input layer. Warning: MXNet Parser has not supported operator null with name label. Warning: convert the null operator with name [label] into input layer. [14:37:20] /mxnet/dmlc-core/include/dmlc/./logging.h:308: **[14:37:20] src/c_api/c_api_symbolic.cc:417: InferShapeKeyword argument name data not found. Candidate arguments: [0]label**
infer_shape error. Arguments: data: (1, 3, 512, 512) Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 159, in <module> _main() File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 154, in _main ret = _convert(args) File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 95, in _convert parser.gen_IR() File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/mxnet/mxnet_parser.py", line 269, in gen_IR self.rename_UNKNOWN(current_node) File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/mxnet/mxnet_parser.py", line 388, in rename_UNKNOWN self.set_output_shape(source_node, IR_node) File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/mxnet/mxnet_parser.py", line 285, in set_output_shape arg_shape, output_shape, aux_shape = sym.infer_shape(data = self.data_shape) File "/mxnet/python/mxnet/symbol/symbol.py", line 965, in infer_shape res = self._infer_shape_impl(False, *args, **kwargs) File "/mxnet/python/mxnet/symbol/symbol.py", line 1095, in _infer_shape_impl ctypes.byref(complete))) File "/mxnet/python/mxnet/base.py", line 146, in check_call raise MXNetError(py_str(_LIB.MXGetLastError())) **mxnet.base.MXNetError: [14:37:20] src/c_api/c_api_symbolic.cc:417: InferShapeKeyword argument name data not found. Candidate arguments: [0]label**

[FCN support] Error when converting voc-fcn16s/voc-fcn32s from caffe to IR

Hi,

Thank you for fixing the other bugs.

Here is my model: fcn16s, fcn32s

Error message as following:

I1221 09:25:06.127544  6033 layer_factory.hpp:77] Creating layer data
F1221 09:25:06.127624  6033 layer_factory.hpp:81] Check failed: registry.count(type) == 1 (0 vs. 1) Unknown layer type: Python (known types: AbsVal, Accuracy, ArgMax, BNLL, BatchNorm, BatchReindex, Bias, Concat, ContrastiveLoss, Convolution, Crop, Data, Deconvolution, Dropout, DummyData, ELU, Eltwise, Embed, EuclideanLoss, Exp, Filter, Flatten, HDF5Data, HDF5Output, HingeLoss, Im2col, ImageData, InfogainLoss, InnerProduct, Input, LRN, LSTM, LSTMUnit, Log, MVN, MemoryData, MultinomialLogisticLoss, PReLU, Parameter, Pooling, Power, RNN, ReLU, Reduction, Reshape, SPP, Scale, Sigmoid, SigmoidCrossEntropyLoss, Silence, Slice, Softmax, SoftmaxWithLoss, Split, TanH, Threshold, Tile, WindowData)
*** Check failure stack trace: ***
Aborted (core dumped)

Thank you.

Variable nodes in Tensorflow dissapears

I'm trying to convert Tensorflow model to Caffe model.
In procedure from Tensorflow to IR protobuf, variables nodes seemed to dissapear.

Then finally following Caffe code was generated.
'Eltwise' layer needs two input bottoms but only one were assigned,
due to no variable node had been generated in protobuf graph.

n.l1_add_2 = L.Eltwise(n.l1_add_1, operation=1, ntop=1)

Error message

F0306 09:44:31.269845 345 layer.hpp:354] Check failed: MinBottomBlobs() <= bottom.size() (2 vs. 1) Eltwise Layer takes at least 2 bottom blob(s) as input.

I'd appreciate it if MMdnn accepts simple variable layers.

MMDNN Visualizer doesn't show layer config

Platform (like ubuntu 16.04/win10): Ubuntu 16.04

Python version: 3.5

Source framework with version (like Tensorflow 1.4.1 with GPU): Caffe

Destination framework with version (like CNTK 2.3 with GPU): PyTorch

Pre-trained model path (webpath or webdisk path): https://gist.github.com/ksimonyan/a32c9063ec8e1118221a

Running scripts: python -m mmdnn.conversion._script.convertToIR -f caffe -d vggF -n VGG_CNN_F_deploy.prototxt -w VGG_CNN_F.caffemodel


I converted VGG_CNN_F model downloaded from Caffe Model Zoo to IR, then I upload vggF.json to MMdnn model visualizer to get visualization. But the MMdnn model visualizer doesn't show any layer config, it seems to be the javascript issue.

draw.js:96 Uncaught TypeError: Cannot read property 'attr' of undefined
   at selectLayer (draw.js:96)
   at SVGRectElement.<anonymous> (draw.js:215)
   at SVGRectElement.<anonymous> (d3.v4.js:935)

Need to update pip installation

When I tried to update my MMdnn by pip install -U https://github.com/Microsoft/MMdnn/releases/download/0.1.1/mmdnn-0.1.1-py2.py3-none-any.whl , it didn't update the version in master now.

For the setup.py, I tried it but it looked like I have to add some command after it

usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: no commands supplied

And if I use pip install git+https://github.com/Microsoft/MMdnn.git@master, there will be an encoding error:

Collecting git+https://github.com/Microsoft/MMdnn.git@master
  Cloning https://github.com/Microsoft/MMdnn.git (to master) to /tmp/pip-UM6BrV-build
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-UM6BrV-build/setup.py", line 5, in <module>
        with open('README.md', encoding='utf-8') as f:
    TypeError: 'encoding' is an invalid keyword argument for this function

Can you please explain the usage or update it?
Thanks.

Error: Caffe -> IR -> CNTK

I want to convert a SqueezeNet model to CNTK. For instance, https://github.com/DeepScale/SqueezeNet/tree/master/SqueezeNet_v1.1

When I try to generate the CNTK model using the generated python script as well as the .npy file, which I retrieved using the following steps, I am receiving the error posted below.

python -m mmdnn.conversion._script.IRToCode --dstFramework cntk --IRModelPath DSD_SqueezeNet_cmodel.pb --dstModelPath DSD_SqueezeNet_cmodel.py --IRWeightPath DSD_SqueezeNet_cmodel.npy
python -m mmdnn.conversion.examples.cntk.imagenet_test -n DSD_SqueezeNet_cmodel.py -w DSD_SqueezeNet_cmodel.caffemodel --dump DSD_SqueezeNet_cmodel

Error:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\numpy\lib\npyio.py", line 426, in load
    return pickle.load(fid, **pickle_kwargs)
_pickle.UnpicklingError: invalid load key, '\x0a'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "SqueezeNetV1_1_cmodel.py", line 13, in load_weights
    weights_dict = np.load(weight_file).item()
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\numpy\lib\npyio.py", line 429, in load
    "Failed to interpret file %s as a pickle" % repr(file))
OSError: Failed to interpret file 'SqueezeNetV1_1_cmodel.caffemodel' as a pickle

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\numpy\lib\npyio.py", line 426, in load
    return pickle.load(fid, **pickle_kwargs)
_pickle.UnpicklingError: invalid load key, '\x0a'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "MMdnn\mmdnn\conversion\examples\cntk\imagenet_test.py", line 59, in <module>
    tester = TestCNTK()
  File "MMdnn\mmdnn\conversion\examples\cntk\imagenet_test.py", line 24, in __init__
    self.model = self.MainModel.KitModel(self.args.w)
  File "SqueezeNetV1_1_cmodel.py", line 22, in KitModel
    __weights_dict = load_weights(weight_file)
  File "SqueezeNetV1_1_cmodel.py", line 15, in load_weights
    weights_dict = np.load(weight_file, encoding='bytes').item()
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\numpy\lib\npyio.py", line 429, in load
    "Failed to interpret file %s as a pickle" % repr(file))
OSError: Failed to interpret file 'SqueezeNetV1_1_cmodel.caffemodel' as a pickle

IndexError: list index out of range - Tensorflow Model Conversion

python -m mmdnn.conversion._script.convertToIR -f tensorflow -d vgg19 -n xx.ckpt.meta -w xx.ckpt --dstNodeName Add

Tensorflow model file [xx.ckpt.meta] loaded successfully.
Tensorflow checkpoint file [xx.ckpt] loaded successfully.
 [146] variables loaded.

## traceback:
line 472, in rename_RealDiv
    if scopes[-2] == 'dropout':
IndexError: list index out of range

Tensorflow 1.4
MMdnn 0.1.2

ONNX support

Hi, guys.

How does MMdnn relates to ONNX?

Do you guys use it as IR or have plans for that?

Thank you

Convert ResNet101 from TensorFlow to PyTorch

Dear @kitstar,
I want to convert a ResNet V1 101 model (from TF-Slim) to PyTorch. Would you please kindly help me to do that?
Just as another suggestion, I think it would be great if you create a README.md file for PyTorch conversion section.

IndexError: list index out of range

Platform (like ubuntu 16.04/win10):
Win10

Python version:
Python27

Source framework with version (like Tensorflow 1.4.1 with GPU):
MXNet version 1.0.0 (mxnet_cu80), model version is 0.9.4

Destination framework with version (like CNTK 2.3 with GPU):
Caffe

Pre-trained model path (webpath or webdisk path):
http://17064t8y63.51mypc.cn:8000/d/d5c6c4b421/

Running scripts:
python -m mmdnn.conversion._script.convertToIR -f mxnet -n newnet-symbol.json -w newnet-0052.params -d pointnet --inputShape 3 64 64

Running logs

[18:20:32] D:\Program Files (x86)\Jenkins\workspace\mxnet-tag\mxnet\src\nnvm\legacy_json_util.cc:209: Loading symbol saved by previous version v0.9.4. Attempting to upgrade...
[18:20:32] D:\Program Files (x86)\Jenkins\workspace\mxnet-tag\mxnet\src\nnvm\legacy_json_util.cc:217: Symbol successfully upgraded!
E:\ProgramData\Anaconda2\lib\site-packages\mxnet\module\base_module.py:53: UserWarning: You created Module with Module(..., label_names=['softmax_label']) but input with name 'softmax_label' is not found in symbol.list_arguments(). Did you mean one of:
	data
  warnings.warn(msg)
Warning: MXNet Parser has not supported operator null with name data.
Warning: convert the null operator with name [data] into input layer.

Error Message

File "E:\workspace\python\MMdnn\mmdnn\conversion\_script\convertToIR.py", line 140, in <module>
  _main()
File "E:\workspace\python\MMdnn\mmdnn\conversion\_script\convertToIR.py", line 135, in _main
  ret = _convert(args)
File "E:\workspace\python\MMdnn\mmdnn\conversion\_script\convertToIR.py", line 72, in _convert
  parser.run(args.dstPath)
File "E:\ProgramData\Anaconda2\Lib\site-packages\mmdnn\conversion\common\DataStructure\parser.py", line 22, in run
  self.gen_IR()
File "E:\ProgramData\Anaconda2\Lib\site-packages\mmdnn\conversion\mxnet\mxnet_parser.py", line 266, in gen_IR
  func(current_node)
File "E:\ProgramData\Anaconda2\Lib\site-packages\mmdnn\conversion\mxnet\mxnet_parser.py", line 429, in rename_FullyConnected
  channel_first_list = self.trace_shape(source_node, IR_node)
File "E:\ProgramData\Anaconda2\Lib\site-packages\mmdnn\conversion\mxnet\mxnet_parser.py", line 90, in trace_shape
  IR_node = self.IR_layer_map[IR_node.input[0]]
File "E:\ProgramData\Anaconda2\Lib\site-packages\google\protobuf\internal\containers.py", line 204, in __getitem__
  return self._values[key]

IndexError: list index out of range

Convert Special ResNet101 from TensorFlow to PyTorch

Dear @kitstar,
By using your complete tutorial I can convert ResNet V1 101 model (from TF-Slim) to PyTorch, and the converted model works correct. Now I want to convert another ResNet V1 101 model which has 5,000 classes from TensorFlow to PyTorch. In fact, I want to convert the pre-trained Open Images ResNet V1 101 from TensorFlow to PyTorch.
To this end, I have tested with follow steps:

  1. Download resnet_v1_101 data:
$ wget https://storage.googleapis.com/openimages/2017_07/oidv2-resnet_v1_101.ckpt.tar.gz
$ tar -xvf oidv2-resnet_v1_101.ckpt.tar.gz

  1. Extract tf model files:
    python -m mmdnn.conversion.examples.tensorflow.extract_model -n resnet_v1_101 -ckpt oidv2-resnet_v1_101.ckpt.data-00000-of-00001

However, I got a long error like this:

... DataLossError (see above for traceback): Unable to open table file ./oidv2-resnet_v1_101.ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
	 [[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]

I used the TF 1.4.1 and PyTorch 0.3.
Would you please help me to address this issue and do the conversion?

Darknet IR support

Saw that there is this post references that there is no Darknet IR conversion yet.

However, are there any there are unfinished projects in the works that anyone knows of?

Short of that, some documentation/guides on the process of converting from/to the IR itself, that I could look into?

The json file is empty from tensorflow to IR

I try to convert tensorflow to IR, with the following commond:

python -m mmdnn.conversion._script.convertToIR -f tensorflow -d selfDesignNetwork -n selfDesignNetwork.ckpt.meta --dstNodeName output/weights

However the result json file and .pb file is empty .

selfDesignNetwork.ckpt.meta is the .meta file and output/weights is the output node name.

What's wrong with the problem?

Error in conversion from Tensorflow Model to CNTK Model

I have used the code at the link (https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/4_Utils/save_restore_model.py) to create and store a model in tensorflow.

I am converting the saved tensorflow model to cntk using the steps mentioned in MMdnn. At the final step of convresion, i.e. while generating CNTK Model from CNTK Code Snippet, I am getting some error.

Following is the traceback:

(C:\Program Files\Anaconda3\envs\py35) MMdnn-master\mmdnn\conversion\cntk>python -m mmdnn.conversion.examples.cntk.imagenet_test -n cntkModel_3_5.py -w IRModel_3_5.npy --dump cntkModel_3_5.dnn
Traceback (most recent call last):
File "C:\Program Files\Anaconda3\envs\py35\lib\runpy.py", line 184, in _run_mo
dule_as_main
"main", mod_spec)
File "C:\Program Files\Anaconda3\envs\py35\lib\runpy.py", line 85, in _run_cod
e
exec(code, run_globals)
File "C:\Program Files\Anaconda3\envs\py35\lib\site-packages\mmdnn\conversion
examples\cntk\imagenet_test.py", line 57, in
tester = TestCNTK()
File "C:\Program Files\Anaconda3\envs\py35\lib\site-packages\mmdnn\conversion
examples\cntk\imagenet_test.py", line 17, in init
super(TestCNTK, self).init()
File "C:\Program Files\Anaconda3\envs\py35\lib\site-packages\mmdnn\conversion
examples\imagenet_test.py", line 104, in init
self.MainModel = import(self.args.n)
File "D:\Rishi\Machine Learning\CNTK\MMdnn-master\mmdnn\conversion\cntk\cntkMo
del_3_5.py", line 31
Reshape_1 = cntk.reshape(Placeholder_1, shape = (,) name = 'Reshape_1'
)
^
SyntaxError: invalid syntax

PReLU is not support yet?

Platform (ubuntu 16.04):

Python version: 2.7

Follow issue happens when use PReLU layer, can you support it?
thanks.

Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 140, in
_main()
File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 135, in _main
ret = _convert(args)
File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 9, in _convert
transformer = CaffeTransformer(args.network, args.weights, "tensorflow", args.inputShape, phase = args.caffePhase)
File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/caffe/transformer.py", line 316, in init
graph = GraphBuilder(def_path, self.input_shape, self.is_train_proto, phase).build()
File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/caffe/graph.py", line 447, in build
graph.compute_output_shapes(self.model)
File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/caffe/graph.py", line 266, in compute_output_shapes
node.output_shape = TensorShape(*NodeKind.compute_output_shape(node))
File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/caffe/graph.py", line 126, in compute_output_shape
return LAYER_DESCRIPTORSnode.kind
KeyError: None

how to convert vggm from caffe to mxnet

Hi, I have a question about how to convert vggm from caffe to mxnet, I have test the vgg19 and vgg16 can convert from caffe to mxnet successful, but the vggm doesn't work, the err is "axes don't match array"。I found that the MMdnn have test the vgg19 and googlenet . is this vggm supported?thank you.

IR->Caffe?

Hi,
In the Caffe directory there is no instruction for IR ->Caffe conversion. Is this conversion supported?
I want to convert the weights in keras to caffe. How can I do this conversion using MMdnn?
Thank you.

Error when converting VGG16_SOD from caffe to tensorflow

Hi,

Here's the model: link

Again this happens when trying to convert from IR to tensorflow, but with different error code:

Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/examples/tensorflow/imagenet_test.py", line 68, in <module>
    tester = TestTF()
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/examples/tensorflow/imagenet_test.py", line 16, in __init__
    super(TestTF, self).__init__()
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/examples/imagenet_test.py", line 119, in __init__
    self.MainModel = __import__(self.args.n)
  File "VGG16_SOD.py", line 81
    fc8-SOD100_0    = tf.contrib.layers.flatten(relu7)
SyntaxError: can't assign to operator

Can you please check it out?

Thank you.

Error when converting inception-v4 from caffe to tensorflow

Hi,

This is my model: link
When I tried to convert it from IR to tensorflow, an error popped out:

Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/examples/tensorflow/imagenet_test.py", line 68, in <module>
    tester = TestTF()
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/examples/tensorflow/imagenet_test.py", line 17, in __init__
    self.input, self.model = self.MainModel.KitModel(self.args.w)
  File "inception_v4.py", line 57, in KitModel
    inception_stem2_7x1_pad = tf.pad(inception_stem2_1x7_relu, paddings = [[0L, 0L], [3L, 3L], [3L, -3L], [0L, 0L]])
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 1735, in pad
    result = gen_array_ops._pad(tensor, paddings, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 2927, in _pad
    "Pad", input=input, paddings=paddings, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2958, in create_op
    set_shapes_for_outputs(ret)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2209, in set_shapes_for_outputs
    shapes = shape_func(op)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2159, in call_with_requiring
    return call_cpp_shape_fn(op, require_shape_fn=True)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/common_shapes.py", line 627, in call_cpp_shape_fn
    require_shape_fn)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/common_shapes.py", line 691, in _call_cpp_shape_fn_impl
    raise ValueError(err.message)
ValueError: Paddings must be non-negative for 'Pad_4' (op: 'Pad') with input shapes: [?,73,73,64], [4,2] and with computed input tensors: input[1] = <[0 0][3 3][3 -3][0 0]>.

Does it mean this model is impossible to convert?
Or is there any wrong with the model?

Thank you.

from tensorflow to mxnet

Hi @kitstar , I want to convert tensorlflow to mxnet. however, I encounter a bug when I run the following script:
python -m mmdnn.conversion._script.IRToCode -f mxnet -d converted_mxnet.py -n converted.pb -w converted.npy

Before that, I get 'imagenet_inception_v3.json', 'imagenet_inception_v3.h5', 'converted.json', 'converted.pb' and 'converted.npy' successfully as the example (from tensorflow to CNTK) provided in the README.

The bug is:
Parse file [converted.pb] with binary format successfully. Detect input layer [input_1] using infer batch size, set it as default value [1] Traceback (most recent call last): File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/media/disk1/xxx/code/projects/tensorflow-models/MMdnn/mmdnn/conversion/_script/IRToCode.py", line 120, in <module> _main() File "/media/disk1/xxx/code/projects/tensorflow-models/MMdnn/mmdnn/conversion/_script/IRToCode.py", line 115, in _main ret = _convert(args) File "/media/disk1/xxx/code/projects/tensorflow-models/MMdnn/mmdnn/conversion/_script/IRToCode.py", line 56, in _convert emitter.run(args.dstModelPath, args.dstWeightPath, args.phase) File "mmdnn/conversion/common/DataStructure/emitter.py", line 21, in run self.save_code(dstNetworkPath, phase) File "mmdnn/conversion/common/DataStructure/emitter.py", line 53, in save_code code = self.gen_code(phase) File "mmdnn/conversion/mxnet/mxnet_emitter.py", line 120, in gen_code dirname = os.path.dirname(self.output_weights_file) File "/home/xxx/softwares/tensorflow/lib64/python2.7/posixpath.py", line 129, in dirname i = p.rfind('/') + 1 AttributeError: 'NoneType' object has no attribute 'rfind'

What is the problem?

Error when inception_v3 from tensorflow-IR convert to mxnet

OS: CentOS7.0
tensorflow: 1.4.1
mxnet: 1.0.0

I download pre-train model from inception_v3_2016_08_28.tar.gz

I follow these steps:

  1. Use python to extract both network architecture and weights
    python -m mmdnn.conversion.examples.tensorflow.extract_model -n inception_v3 -ckpt ./inception_v3.ckpt
  2. Convert model (including architecture and weights) from Tensorflow to IR
    python -m mmdnn.conversion._script.convertToIR -f tensorflow -d inception_v3 -n imagenet_inception_v3.ckpt.meta -w inception_v3.ckpt --dstNodeName Squeeze
  3. Convert models from IR to MXNet code snippet and weights
    python -m mmdnn.conversion._script.IRToCode -f mxnet --IRModelPath inception_v3.pb --dstModelPath mxnet_inception_v3.py --IRWeightPath inception_v3.npy -dw ./mxnet_inception_v3-0000.params
  4. Convert models from IR to MXNet checkpoint file
    python -m mmdnn.conversion.examples.mxnet.imagenet_test -n mxnet_inception_v3 -w mxnet_inception_v3-0000.params --dump inception_v3

Step 1-3 works well, but step 4 reports some warning:
/usr/lib/python2.7/site-packages/mxnet/module/base_module.py:53: UserWarning: You created Module with Module(..., label_names=['softmax_label']) but input with name 'softmax_label' is not found in symbol.list_arguments(). Did you mean one of: input warnings.warn(msg) /usr/lib/python2.7/site-packages/mxnet/module/base_module.py:65: UserWarning: Data provided by label_shapes don't match names specified by label_names ([] vs. ['softmax_label']) warnings.warn(msg) MXNet checkpoint file is saved with prefix [inception_v3] and iteration 0, generated by [mxnet_inception_v3.py] and [mxnet_inception_v3-0000.params].

After step 4, inception_v3-symbol.json and inception_v3-0000.params generated. When I test these file using sym, arg_params, aux_params = mx.model.load_checkpoint('inception_v3', 0) mod = mx.mod.Module(symbol=sym, context=mx.cpu(), label_names=None), the error occurs:
Traceback (most recent call last): File "inception_v3-loading.py", line 10, in <module> mod = mx.mod.Module(symbol=sym, context=mx.cpu(), label_names=None) File "/usr/lib/python2.7/site-packages/mxnet/module/module.py", line 93, in __init__ _check_input_names(symbol, data_names, "data", True) File "/usr/lib/python2.7/site-packages/mxnet/module/base_module.py", line 51, in _check_input_names raise ValueError(msg) ValueError: You created Module with Module(..., data_names=['data']) but input with name 'data' is not found in symbol.list_arguments(). Did you mean one of: input

Could someone help me?

Error (Caffe->IR)

When I try to get the intermediate representation of a caffemodel, I get the following error:

class args( object ):
    srcFramework = 'caffe' 
    dstPath = destinationFilePrefix
    network = structureFile
    weights = weightFile
    inputShape = [3, 227, 227]
    caffePhase = 'TRAIN'
convertToIR._convert( args() )
 ------------------------------------------------------------
    WARNING: PyCaffe not found!
    Falling back to a pure protocol buffer implementation.
    * Conversions will be drastically slower.
    * This backend is UNTESTED!
------------------------------------------------------------

Traceback (most recent call last):
File "convertToIR.py", line 9, in _convert
    transformer = CaffeTransformer(args.network, args.weights, "tensorflow", args.inputShape, phase = args.caffePhase)

File "transformer.py", line 316, in __init__
    graph = GraphBuilder(def_path, self.input_shape, self.is_train_proto, phase).build()

File "graph.py", line 446, in build
    graph.compute_output_shapes(self.model)

File "graph.py", line 270, in compute_output_shapes
    node.output_shape = TensorShape(*NodeKind.compute_output_shape(node))

File "graph.py", line 125, in compute_output_shape
    return LAYER_DESCRIPTORS[node.kind](node)

File "shape.py", line 97, in shape_pool
    return get_strided_kernel_output_shape(node, math.ceil)

File "shape.py", line 24, in get_strided_kernel_output_shape
    dilation = 1 if len(node.parameters.dilation) == 0 else node.parameters.dilation[0]
AttributeError: 'PoolingParameter' object has no attribute 'dilation'

Happens with https://github.com/DeepScale/SqueezeNet/tree/master/SqueezeNet_v1.1
as well as with https://github.com/songhan/SqueezeNet-DSD-Training

Convert Model from MXNet to PyTorch

Dear @kitstar,
Thank you for your nice repository. I have a pre-trained ResNet152 model on MXNet and I want to convert it to PyTorch. Would you please kindly guide me to do that?

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.