Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

from tensorflow to mxnet #30

Closed
JackieLeeTHU11 opened this issue Dec 22, 2017 · 6 comments
Closed

from tensorflow to mxnet #30

JackieLeeTHU11 opened this issue Dec 22, 2017 · 6 comments

Comments

@JackieLeeTHU11
Copy link

JackieLeeTHU11 commented Dec 22, 2017

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?

@kitstar
Copy link
Contributor

kitstar commented Dec 22, 2017

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.

@JackieLeeTHU11
Copy link
Author

@kitstar It works well, thanks.

@kitstar kitstar closed this as completed Dec 23, 2017
@Albert-Ye
Copy link

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'

@kitstar
Copy link
Contributor

kitstar commented Apr 18, 2018

Should be fixed in newest mmdnn.

@ZHEQIUSHUI
Copy link

我输入
"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.”
啥原因啊

@CorvusVaine
Copy link

CorvusVaine commented Jun 17, 2021

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants