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

Error in converting Caffe model to Keras #720

Open
caesar84 opened this issue Aug 18, 2019 · 6 comments

Comments

@caesar84
Copy link

commented Aug 18, 2019

Platform (like ubuntu 16.04/win10):

Python version:

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

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

Pre-trained model path (webpath or webdisk path):
TrailNet_SResNet-18
Running scripts:
root@88d618bfdf67:/mmdnn# mmconvert -sf caffe -in TrailNet_SResNet-18.prototxt -iw TrailNet_SResNet-18.caffemodel -df keras -om TrailNet_SResNet-18.h5

i run the above command to convert a pre-trained model (TrailNet_SResNet-18
) to keras after installing the docker CE per installations instaructions. i have this error :

WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
Type Name Param Output

Data data -- (1, 3, 180, 320)
Scale sub_mean (3,) (1, 3, 180, 320)
Convolution conv1 (7, 7, 3, 64) (1, 64, 87, 157)
Scale conv1_srelu1_1 (64,) (1, 64, 87, 157)
ReLU conv1_srelu1_2 -- (1, 64, 87, 157)
Scale conv1_srelu1_3 (64,) (1, 64, 87, 157)
Pooling pool1 -- (1, 64, 43, 78)
Convolution res1_1_1 (3, 3, 64, 64) (1, 64, 43, 78)
Scale res1_1_1_srelu_1 (64,) (1, 64, 43, 78)
ReLU res1_1_1_srelu_2 -- (1, 64, 43, 78)
Scale res1_1_1_srelu_3 (64,) (1, 64, 43, 78)
Convolution res1_1_2 (3, 3, 64, 64) (1, 64, 43, 78)
Eltwise res1_1_sum -- (1, 64, 43, 78)
Scale res1_1_srelu_1 (64,) (1, 64, 43, 78)
ReLU res1_1_srelu_2 -- (1, 64, 43, 78)
Scale res1_1_srelu_3 (64,) (1, 64, 43, 78)
Convolution res1_2_1 (3, 3, 64, 64) (1, 64, 43, 78)
Scale res1_2_1_srelu_1 (64,) (1, 64, 43, 78)
ReLU res1_2_1_srelu_2 -- (1, 64, 43, 78)
Scale res1_2_1_srelu_3 (64,) (1, 64, 43, 78)
Convolution res1_2_2 (3, 3, 64, 64) (1, 64, 43, 78)
Eltwise res1_2_sum -- (1, 64, 43, 78)
Scale res1_2_srelu_1 (64,) (1, 64, 43, 78)
ReLU res1_2_srelu_2 -- (1, 64, 43, 78)
Scale res1_2_srelu_3 (64,) (1, 64, 43, 78)
Convolution res2_1_1 (3, 3, 64, 128) (1, 128, 43, 78)
Scale res2_1_1_srelu_1 (128,) (1, 128, 43, 78)
ReLU res2_1_1_srelu_2 -- (1, 128, 43, 78)
Scale res2_1_1_srelu_3 (128,) (1, 128, 43, 78)
Convolution res2_1_2 (3, 3, 128, 128) (1, 128, 22, 39)
Convolution res2_1_proj (1, 1, 64, 128) (1, 128, 22, 39)
Eltwise res2_1_sum -- (1, 128, 22, 39)
Scale res2_1_srelu_1 (128,) (1, 128, 22, 39)
ReLU res2_1_srelu_2 -- (1, 128, 22, 39)
Scale res2_1_srelu_3 (128,) (1, 128, 22, 39)
Convolution res2_2_1 (3, 3, 128, 128) (1, 128, 22, 39)
Scale res2_2_1_srelu_1 (128,) (1, 128, 22, 39)
ReLU res2_2_1_srelu_2 -- (1, 128, 22, 39)
Scale res2_2_1_srelu_3 (128,) (1, 128, 22, 39)
Convolution res2_2_2 (3, 3, 128, 128) (1, 128, 22, 39)
Eltwise res2_2_sum -- (1, 128, 22, 39)
Scale res2_2_srelu_1 (128,) (1, 128, 22, 39)
ReLU res2_2_srelu_2 -- (1, 128, 22, 39)
Scale res2_2_srelu_3 (128,) (1, 128, 22, 39)
Convolution res3_1_1 (3, 3, 128, 256) (1, 256, 22, 39)
Scale res3_1_1_srelu_1 (256,) (1, 256, 22, 39)
ReLU res3_1_1_srelu_2 -- (1, 256, 22, 39)
Scale res3_1_1_srelu_3 (256,) (1, 256, 22, 39)
Convolution res3_1_2 (3, 3, 256, 256) (1, 256, 11, 20)
Convolution res3_1_proj (1, 1, 128, 256) (1, 256, 11, 20)
Eltwise res3_1_sum -- (1, 256, 11, 20)
Scale res3_1_srelu_1 (256,) (1, 256, 11, 20)
ReLU res3_1_srelu_2 -- (1, 256, 11, 20)
Scale res3_1_srelu_3 (256,) (1, 256, 11, 20)
Convolution res3_2_1 (3, 3, 256, 256) (1, 256, 11, 20)
Scale res3_2_1_srelu_1 (256,) (1, 256, 11, 20)
ReLU res3_2_1_srelu_2 -- (1, 256, 11, 20)
Scale res3_2_1_srelu_3 (256,) (1, 256, 11, 20)
Convolution res3_2_2 (3, 3, 256, 256) (1, 256, 11, 20)
Eltwise res3_2_sum -- (1, 256, 11, 20)
Scale res3_2_srelu_1 (256,) (1, 256, 11, 20)
ReLU res3_2_srelu_2 -- (1, 256, 11, 20)
Scale res3_2_srelu_3 (256,) (1, 256, 11, 20)
Convolution res4_1_1 (3, 3, 256, 512) (1, 512, 11, 20)
Scale res4_1_1_srelu_1 (512,) (1, 512, 11, 20)
ReLU res4_1_1_srelu_2 -- (1, 512, 11, 20)
Scale res4_1_1_srelu_3 (512,) (1, 512, 11, 20)
Convolution res4_1_2 (3, 3, 512, 512) (1, 512, 6, 10)
Convolution res4_1_proj (1, 1, 256, 512) (1, 512, 6, 10)
Eltwise res4_1_sum -- (1, 512, 6, 10)
Scale res4_1_srelu_1 (512,) (1, 512, 6, 10)
ReLU res4_1_srelu_2 -- (1, 512, 6, 10)
Scale res4_1_srelu_3 (512,) (1, 512, 6, 10)
Convolution res4_2_1 (3, 3, 512, 512) (1, 512, 6, 10)
Scale res4_2_1_srelu_1 (512,) (1, 512, 6, 10)
ReLU res4_2_1_srelu_2 -- (1, 512, 6, 10)
Scale res4_2_1_srelu_3 (512,) (1, 512, 6, 10)
Convolution res4_2_2 (3, 3, 512, 512) (1, 512, 6, 10)
Eltwise res4_2_sum -- (1, 512, 6, 10)
Scale res4_2_srelu_1 (512,) (1, 512, 6, 10)
ReLU res4_2_srelu_2 -- (1, 512, 6, 10)
Scale res4_2_srelu_3 (512,) (1, 512, 6, 10)
Pooling pool_avg -- (1, 512, 4, 8)
InnerProduct fc3 (16384, 3) (1, 3, 1, 1)
Softmax softmax -- (1, 3, 1, 1)
InnerProduct fc3_t (16384, 3) (1, 3, 1, 1)
Softmax softmax_t -- (1, 3, 1, 1)
Concat concat -- (1, 6, 1, 1)
Traceback (most recent call last):
File "/usr/local/bin/mmconvert", line 11, in
sys.exit(_main())
File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/_script/convert.py", line 102, in _main
ret = convertToIR._convert(ir_args)
File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 10, in _convert
graph = transformer.transform_graph()
File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/caffe/transformer.py", line 360, in transform_graph
mapped_node = self.map_node(node)
File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/caffe/transformer.py", line 381, in map_node
mapped_node = map_func(node)
File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/caffe/mapper.py", line 237, in map_scale
raise NotImplementedError
NotImplementedError

Anyone can help me if I wrote the command wrongly? or its another issue?

ps, i had cut the first part of the output because it was ok .

@rainLiuplus

This comment has been minimized.

Copy link
Collaborator

commented Sep 9, 2019

Hi @caesar84, could you upload your model for us to debug? Thanks!

@caesar84

This comment has been minimized.

Copy link
Author

commented Sep 9, 2019

hi @rainLiuplus
I have tried to upload the model ( Prototxt and caffemodel files ) But they are too big as the caffemodel file is about 44 Mb.
so, could you please download the files from the official Nvidia team here :
https://raw.githubusercontent.com/NVIDIA-AI-IOT/redtail/master/models/pretrained/TrailNet_SResNet-18.prototxt

https://raw.githubusercontent.com/NVIDIA-AI-IOT/redtail/master/models/pretrained/TrailNet_SResNet-18.caffemodel

I am thankful for your effort and I would appreciate it if you would be able to convert it to a Keras or ONNX model .

@rainLiuplus

This comment has been minimized.

Copy link
Collaborator

commented Sep 11, 2019

Hi @caesar84, the caffe [Scale] has been added, please check the lastest master.

After clone it, you could run below script at the root of your MMdnn folder:

export PYTHONPATH=.
python -m mmdnn.conversion._script.convert -sf caffe -in TrailNet_SResNet-18.prototxt -iw TrailNet_SResNet-18.caffemodel -df keras -om TrailNet_SResNet-18.h5
@caesar84

This comment has been minimized.

Copy link
Author

commented Sep 11, 2019

hi @rainLiuplus
thanks for your reply I do really appreciate it. I followed your instructions and here is the output

` WARNING: PyCaffe not found!
Falling back to a pure protocol buffer implementation.
* Conversions will be drastically slower.
* This backend is UNTESTED!

Warning: parameters not reshaped for node: [Scale] sub_mean
Warning: parameters not reshaped for node: [Scale] conv1_srelu1_1
Warning: parameters not reshaped for node: [Scale] conv1_srelu1_3
Warning: parameters not reshaped for node: [Scale] res1_1_1_srelu_1
Warning: parameters not reshaped for node: [Scale] res1_1_1_srelu_3
Warning: parameters not reshaped for node: [Scale] res1_1_srelu_1
Warning: parameters not reshaped for node: [Scale] res1_1_srelu_3
Warning: parameters not reshaped for node: [Scale] res1_2_1_srelu_1
Warning: parameters not reshaped for node: [Scale] res1_2_1_srelu_3
Warning: parameters not reshaped for node: [Scale] res1_2_srelu_1
Warning: parameters not reshaped for node: [Scale] res1_2_srelu_3
Warning: parameters not reshaped for node: [Scale] res2_1_1_srelu_1
Warning: parameters not reshaped for node: [Scale] res2_1_1_srelu_3
Warning: parameters not reshaped for node: [Scale] res2_1_srelu_1
Warning: parameters not reshaped for node: [Scale] res2_1_srelu_3
Warning: parameters not reshaped for node: [Scale] res2_2_1_srelu_1
Warning: parameters not reshaped for node: [Scale] res2_2_1_srelu_3
Warning: parameters not reshaped for node: [Scale] res2_2_srelu_1
Warning: parameters not reshaped for node: [Scale] res2_2_srelu_3
Warning: parameters not reshaped for node: [Scale] res3_1_1_srelu_1
Warning: parameters not reshaped for node: [Scale] res3_1_1_srelu_3
Warning: parameters not reshaped for node: [Scale] res3_1_srelu_1
Warning: parameters not reshaped for node: [Scale] res3_1_srelu_3
Warning: parameters not reshaped for node: [Scale] res3_2_1_srelu_1
Warning: parameters not reshaped for node: [Scale] res3_2_1_srelu_3
Warning: parameters not reshaped for node: [Scale] res3_2_srelu_1
Warning: parameters not reshaped for node: [Scale] res3_2_srelu_3
Warning: parameters not reshaped for node: [Scale] res4_1_1_srelu_1
Warning: parameters not reshaped for node: [Scale] res4_1_1_srelu_3
Warning: parameters not reshaped for node: [Scale] res4_1_srelu_1
Warning: parameters not reshaped for node: [Scale] res4_1_srelu_3
Warning: parameters not reshaped for node: [Scale] res4_2_1_srelu_1
Warning: parameters not reshaped for node: [Scale] res4_2_1_srelu_3
Warning: parameters not reshaped for node: [Scale] res4_2_srelu_1
Warning: parameters not reshaped for node: [Scale] res4_2_srelu_3
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
WARNING: Unhandled parameters: Scale
Type Name Param Output

Data data -- (1, 3, 180, 320)
Scale sub_mean (1, 1, 1, 3) (1, 3, 180, 320)
Convolution conv1 (7, 7, 3, 64) (1, 64, 87, 157)
Scale conv1_srelu1_1 (1, 1, 1, 64) (1, 64, 87, 157)
ReLU conv1_srelu1_2 -- (1, 64, 87, 157)
Scale conv1_srelu1_3 (1, 1, 1, 64) (1, 64, 87, 157)
Pooling pool1 -- (1, 64, 43, 78)
Convolution res1_1_1 (3, 3, 64, 64) (1, 64, 43, 78)
Scale res1_1_1_srelu_1 (1, 1, 1, 64) (1, 64, 43, 78)
ReLU res1_1_1_srelu_2 -- (1, 64, 43, 78)
Scale res1_1_1_srelu_3 (1, 1, 1, 64) (1, 64, 43, 78)
Convolution res1_1_2 (3, 3, 64, 64) (1, 64, 43, 78)
Eltwise res1_1_sum -- (1, 64, 43, 78)
Scale res1_1_srelu_1 (1, 1, 1, 64) (1, 64, 43, 78)
ReLU res1_1_srelu_2 -- (1, 64, 43, 78)
Scale res1_1_srelu_3 (1, 1, 1, 64) (1, 64, 43, 78)
Convolution res1_2_1 (3, 3, 64, 64) (1, 64, 43, 78)
Scale res1_2_1_srelu_1 (1, 1, 1, 64) (1, 64, 43, 78)
ReLU res1_2_1_srelu_2 -- (1, 64, 43, 78)
Scale res1_2_1_srelu_3 (1, 1, 1, 64) (1, 64, 43, 78)
Convolution res1_2_2 (3, 3, 64, 64) (1, 64, 43, 78)
Eltwise res1_2_sum -- (1, 64, 43, 78)
Scale res1_2_srelu_1 (1, 1, 1, 64) (1, 64, 43, 78)
ReLU res1_2_srelu_2 -- (1, 64, 43, 78)
Scale res1_2_srelu_3 (1, 1, 1, 64) (1, 64, 43, 78)
Convolution res2_1_1 (3, 3, 64, 128) (1, 128, 43, 78)
Scale res2_1_1_srelu_1 (1, 1, 1, 128) (1, 128, 43, 78)
ReLU res2_1_1_srelu_2 -- (1, 128, 43, 78)
Scale res2_1_1_srelu_3 (1, 1, 1, 128) (1, 128, 43, 78)
Convolution res2_1_2 (3, 3, 128, 128) (1, 128, 22, 39)
Convolution res2_1_proj (1, 1, 64, 128) (1, 128, 22, 39)
Eltwise res2_1_sum -- (1, 128, 22, 39)
Scale res2_1_srelu_1 (1, 1, 1, 128) (1, 128, 22, 39)
ReLU res2_1_srelu_2 -- (1, 128, 22, 39)
Scale res2_1_srelu_3 (1, 1, 1, 128) (1, 128, 22, 39)
Convolution res2_2_1 (3, 3, 128, 128) (1, 128, 22, 39)
Scale res2_2_1_srelu_1 (1, 1, 1, 128) (1, 128, 22, 39)
ReLU res2_2_1_srelu_2 -- (1, 128, 22, 39)
Scale res2_2_1_srelu_3 (1, 1, 1, 128) (1, 128, 22, 39)
Convolution res2_2_2 (3, 3, 128, 128) (1, 128, 22, 39)
Eltwise res2_2_sum -- (1, 128, 22, 39)
Scale res2_2_srelu_1 (1, 1, 1, 128) (1, 128, 22, 39)
ReLU res2_2_srelu_2 -- (1, 128, 22, 39)
Scale res2_2_srelu_3 (1, 1, 1, 128) (1, 128, 22, 39)
Convolution res3_1_1 (3, 3, 128, 256) (1, 256, 22, 39)
Scale res3_1_1_srelu_1 (1, 1, 1, 256) (1, 256, 22, 39)
ReLU res3_1_1_srelu_2 -- (1, 256, 22, 39)
Scale res3_1_1_srelu_3 (1, 1, 1, 256) (1, 256, 22, 39)
Convolution res3_1_2 (3, 3, 256, 256) (1, 256, 11, 20)
Convolution res3_1_proj (1, 1, 128, 256) (1, 256, 11, 20)
Eltwise res3_1_sum -- (1, 256, 11, 20)
Scale res3_1_srelu_1 (1, 1, 1, 256) (1, 256, 11, 20)
ReLU res3_1_srelu_2 -- (1, 256, 11, 20)
Scale res3_1_srelu_3 (1, 1, 1, 256) (1, 256, 11, 20)
Convolution res3_2_1 (3, 3, 256, 256) (1, 256, 11, 20)
Scale res3_2_1_srelu_1 (1, 1, 1, 256) (1, 256, 11, 20)
ReLU res3_2_1_srelu_2 -- (1, 256, 11, 20)
Scale res3_2_1_srelu_3 (1, 1, 1, 256) (1, 256, 11, 20)
Convolution res3_2_2 (3, 3, 256, 256) (1, 256, 11, 20)
Eltwise res3_2_sum -- (1, 256, 11, 20)
Scale res3_2_srelu_1 (1, 1, 1, 256) (1, 256, 11, 20)
ReLU res3_2_srelu_2 -- (1, 256, 11, 20)
Scale res3_2_srelu_3 (1, 1, 1, 256) (1, 256, 11, 20)
Convolution res4_1_1 (3, 3, 256, 512) (1, 512, 11, 20)
Scale res4_1_1_srelu_1 (1, 1, 1, 512) (1, 512, 11, 20)
ReLU res4_1_1_srelu_2 -- (1, 512, 11, 20)
Scale res4_1_1_srelu_3 (1, 1, 1, 512) (1, 512, 11, 20)
Convolution res4_1_2 (3, 3, 512, 512) (1, 512, 6, 10)
Convolution res4_1_proj (1, 1, 256, 512) (1, 512, 6, 10)
Eltwise res4_1_sum -- (1, 512, 6, 10)
Scale res4_1_srelu_1 (1, 1, 1, 512) (1, 512, 6, 10)
ReLU res4_1_srelu_2 -- (1, 512, 6, 10)
Scale res4_1_srelu_3 (1, 1, 1, 512) (1, 512, 6, 10)
Convolution res4_2_1 (3, 3, 512, 512) (1, 512, 6, 10)
Scale res4_2_1_srelu_1 (1, 1, 1, 512) (1, 512, 6, 10)
ReLU res4_2_1_srelu_2 -- (1, 512, 6, 10)
Scale res4_2_1_srelu_3 (1, 1, 1, 512) (1, 512, 6, 10)
Convolution res4_2_2 (3, 3, 512, 512) (1, 512, 6, 10)
Eltwise res4_2_sum -- (1, 512, 6, 10)
Scale res4_2_srelu_1 (1, 1, 1, 512) (1, 512, 6, 10)
ReLU res4_2_srelu_2 -- (1, 512, 6, 10)
Scale res4_2_srelu_3 (1, 1, 1, 512) (1, 512, 6, 10)
Pooling pool_avg -- (1, 512, 4, 8)
InnerProduct fc3 (16384, 3) (1, 3, 1, 1)
Softmax softmax -- (1, 3, 1, 1)
InnerProduct fc3_t (16384, 3) (1, 3, 1, 1)
Softmax softmax_t -- (1, 3, 1, 1)
Concat concat -- (1, 6, 1, 1)
IR network structure is saved as [434fc6be41ab4938895410494cc57767.json].
IR network structure is saved as [434fc6be41ab4938895410494cc57767.pb].
IR weights are saved as [434fc6be41ab4938895410494cc57767.npy].
Using TensorFlow backend.
Parse file [434fc6be41ab4938895410494cc57767.pb] with binary format successfully.
Target network code snippet is saved as [434fc6be41ab4938895410494cc57767.py].
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py:517: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py:4138: The name tf.random_uniform is deprecated. Please use tf.random.uniform instead.

WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py:74: The name tf.get_default_graph is deprecated. Please use tf.compat.v1.get_default_graph instead.

WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py:3976: The name tf.nn.max_pool is deprecated. Please use tf.nn.max_pool2d instead.

WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py:3980: The name tf.nn.avg_pool is deprecated. Please use tf.nn.avg_pool2d instead.

434fc6be41ab4938895410494cc57767.py:47: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
if 'weights' in cur_dict:
434fc6be41ab4938895410494cc57767.py:49: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
if 'bias' in cur_dict:
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py:174: The name tf.get_default_session is deprecated. Please use tf.compat.v1.get_default_session instead.

WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py:181: The name tf.ConfigProto is deprecated. Please use tf.compat.v1.ConfigProto instead.

2019-09-11 16:15:35.674816: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2019-09-11 16:15:35.682960: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3599995000 Hz
2019-09-11 16:15:35.683149: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x2dbfac0 executing computations on platform Host. Devices:
2019-09-11 16:15:35.683202: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): ,
2019-09-11 16:15:35.966707: W tensorflow/compiler/jit/mark_for_compilation_pass.cc:1412] (One-time warning): Not using XLA:CPU for cluster because envvar TF_XLA_FLAGS=--tf_xla_cpu_global_jit was not set. If you want XLA:CPU, either set that envvar, or use experimental_jit_scope to enable XLA:CPU. To confirm that XLA is active, pass --vmodule=xla_compilation_cache=1 (as a proper command-line flag, not via TF_XLA_FLAGS) or set the envvar XLA_FLAGS=--xla_hlo_profile.
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/convert.py", line 123, in
_main()
File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/_script/convert.py", line 112, in _main
dump_code(args.dstFramework, network_filename + '.py', temp_filename + '.npy', args.outputModel, args.dump_tag)
File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/_script/dump_code.py", line 32, in dump_code
save_model(MainModel, network_filepath, weight_filepath, dump_filepath)
File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/keras/saver.py", line 2, in save_model
model = MainModel.KitModel(weight_filepath)
File "434fc6be41ab4938895410494cc57767.py", line 171, in KitModel
set_layer_weights(model, weights_dict)
File "434fc6be41ab4938895410494cc57767.py", line 51, in set_layer_weights
model.get_layer(layer.name).set_weights(current_layer_parameters)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/base_layer.py", line 1057, in set_weights
'provided weight shape ' + str(w.shape))
ValueError: Layer weight shape (64,) not compatible with provided weight shape (1, 1, 1, 64)`

Although it did manage to create IR version of the Network, I still encounter a couple of errors.

I guess you tried the new code on the TrailNet_SResNet-18 for testing, would it be possible for you to share with me the converted Keras model so I can try to import it into Matlab? if so I would be so grateful.
I have to try import Keras and ONNX models of the same network in case anyone might not work so your help is appreciated in advance.

@rainLiuplus

This comment has been minimized.

Copy link
Collaborator

commented Sep 11, 2019

Here is the model: https://drive.google.com/open?id=1czn6DqAoCoin_ev3W2Kp5ktniwxlJnh-

But I could successfully convert the model in local, like
image

May I ask your keras version?

Thanks!

@caesar84

This comment has been minimized.

Copy link
Author

commented Sep 13, 2019

hi @rainLiuplus
firstly, thank you for your great help and quick response.
Basically, I am trying to convert the original Caffe model into Matlab model. This can be done via importing either caffe, Keras or ONNX model. Caffe importer has some limitations in Matlab so I moved to Keras and ONNX. I tried to use your Keras resulted model but unfortunately, it gave me an error which has been reported to Matlab support already for a possible solution.
Next, I tried again to convert the Keras model to ONNX then see if Matlab can import it successfully.
I tried https://github.com/onnx/onnx-docker and it didn't go very well. I will post the images of the error here if you are interested. Also, I tried this https://github.com/onnx/keras-onnx and still no progress.
ONNX_1
ONNX_2
Keras-onnx error

I dont know what to do else at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.