microsoft / MMdnn

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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

from tensorflow to mxnet

JackieLeeTHU11 opened this issue · comments

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?

For mxnet emitter, you should set a output mxnet checkpoint name, such as
python -m mmdnn.conversion._script.IRToCode -f mxnet -dw mxnet_inception_v3-0000.params ...

Thanks.

@kitstar It works well, thanks.

Hi @kitstar , When I convert tensorlflow to mxnet, the following error occurs?

python -m mmdnn.conversion._script.IRToCode -f mxnet --IRModelPath resnet50.pb --dstModelPath mxnet_inception_v3.py --IRWeightPath resnet50.npy -dw mxnet_inception_v3-0000.params

The error is IsADirectoryError: [Errno 21] Is a directory: 'mxnet_inception_v3-0000.params'

Should be fixed in newest mmdnn.

我输入
"python -m mmdnn.conversion._script.convert -sf tensorflow -iw model-20180402-114759.ckpt-275 -in model-20180402-114759.meta -df mxnet -om mxnet_1.param --dump_tag SERVING"
报错
“TypeError: Cannot convert a tensor of type bool to an input of type string

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Arno\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "C:\Users\Arno\Anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Arno\Anaconda3\lib\site-packages\mmdnn\conversion_script\convert.py", line 123, in
_main()
File "C:\Users\Arno\Anaconda3\lib\site-packages\mmdnn\conversion_script\convert.py", line 102, in _main
ret = convertToIR._convert(ir_args)
File "C:\Users\Arno\Anaconda3\lib\site-packages\mmdnn\conversion_script\convertToIR.py", line 66, in _convert
parser = TensorflowParser(args.network, args.weights, args.dstNodeName)
File "C:\Users\Arno\Anaconda3\lib\site-packages\mmdnn\conversion\tensorflow\tensorflow_parser.py", line 314, in init
tensorflow.import_graph_def(transformed_graph_def, name='', input_map=input_map)
File "C:\Users\Arno\Anaconda3\lib\site-packages\tensorflow\python\util\deprecation.py", line 432, in new_func
return func(*args, **kwargs)
File "C:\Users\Arno\Anaconda3\lib\site-packages\tensorflow\python\framework\importer.py", line 671, in import_graph_def
node, 'Input tensor %r %s' % (input_name, te)))
ValueError: graph_def is invalid at node 'enqueue_op': Input tensor 'image_paths:0' Cannot convert a tensor of type bool to an input of type string.”
啥原因啊

Hello, is it possible to convert a h5-stored tensorflow model to MXNet or does it have to be a ckpt file ?
Is it possible to get not only the model, but also the MXNet code ?