MMdnn icon indicating copy to clipboard operation
MMdnn copied to clipboard

Errors when convert TF to Caffe

Open hiigao opened this issue 8 years ago • 2 comments

Platform (like ubuntu 18.04):

Python version: 3.6

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

Destination framework with version (like Caffe 1.0 without GPU):

Pre-trained model path: mmdownload -f tensorflow -n mobilenet_v1_1.0_224

Running scripts: I follow the instructions of the tensorflow to convert the mobilenet_v1_1.0_224.ckpt to caffe model. The command I used in bash is: mmconvert -sf tensorflow -in ./imagenet_mobilenet_v1_1.0.ckpt.meta -iw ./imagenet_mobilenet_v1_1.0.ckpt -df caffe --inputShape 224,224,3 --dstNodeName FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_5_3x3_s2_128/Relu6 --inNodeName Preprocessor/sub -om mobilenet_v1_caffe I directly copy that from the website. But I cann't get the results, the shell show me that: Parse file [./imagenet_mobilenet_v1_1.0.ckpt.meta] with binary format successfully. Tensorflow model file [./imagenet_mobilenet_v1_1.0.ckpt.meta] loaded successfully. Tensorflow checkpoint file [./imagenet_mobilenet_v1_1.0.ckpt] loaded successfully. [137] variables loaded. Traceback (most recent call last): File "/home/hii/.local/bin/mmconvert", line 11, in sys.exit(_main()) File "/home/hii/.local/lib/python2.7/site-packages/mmdnn/conversion/_script/convert.py", line 102, in _main ret = convertToIR._convert(ir_args) File "/home/hii/.local/lib/python2.7/site-packages/mmdnn/conversion/_script/convertToIR.py", line 52, in _convert parser = TensorflowParser(args.network, args.weights, args.dstNodeName, args.inputShape, args.inNodeName) File "/home/hii/.local/lib/python2.7/site-packages/mmdnn/conversion/tensorflow/tensorflow_parser.py", line 206, in init placeholder_type_enum = dtypes.float32.as_datatype_enum) File "/home/hii/.local/lib/python2.7/site-packages/tensorflow/python/tools/strip_unused_lib.py", line 83, in strip_unused raise KeyError("The following input nodes were not found: %s\n" % not_found) KeyError: "The following input nodes were not found: set([u'Preprocessor/sub'])\n"

I guess maybe I miss some files during the mmdnn installation.

I also try the following command: mmtoir -f tensorflow -d mobilenet-v2 -n imagenet_mobilenet_v2_1.0_224.ckpt.meta -w imagenet_mobilenet_v2_1.0_224.ckpt --dstNodeName MMdnn_Output It works this time, but when I use the model in my code, it has errors. Obviously it doesn't been converted correctly.

hiigao avatar Jul 03 '18 07:07 hiigao

Hi @hiigao , It's KeyError: "The following input nodes were not found: set([u'Preprocessor/sub'])\n" ,means this node is not in your checkpoint model file. Please try to figure out which is the right input node. Thanks!

namizzz avatar Jul 04 '18 07:07 namizzz

Hi @hiigao, it is a untimely document updating problem. The README file is already updated. Please try it. If you still want to convert mobilenet_v1 checkpoint file to caffe, you can just use

mmconvert -sf tensorflow -in imagenet_mobilenet_v1_1.0.ckpt.meta -iw imagenet_mobilenet_v1_1.0.ckpt --dstNodeName MMdnn_Output -df caffe -om mobilenet_v1_caffe

And for your own model, you can use vis_meta command to get your own output node, usually the last fully connected layer's bias_add. Thanks.

kitstar avatar Jul 06 '18 10:07 kitstar