MMdnn icon indicating copy to clipboard operation
MMdnn copied to clipboard

Trouble Converting IR to Caffe

Open lamdawr opened this issue 8 years ago • 8 comments

Hi

Platform (like ubuntu 16.04/win10): Ubuntu 14.04

Python version: 3.6 and 2.7

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

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

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

Running scripts:

I get the following error message while trying to create the .caffemodel

File "caffe_model1.py", line 65 print(n.to_proto(), file=fpb) ^ SyntaxError: invalid syntax root@xxxxxxxxxxxx:/xxx/xxx/xxx/kerastocaffe# python caffe_model1.py -w caffe_model1.npy -p caffe_model1.prototxt -m caffe_model1.caffemodel File "caffe_model1.py", line 65 print(n.to_proto(), file=fpb) ^ SyntaxError: invalid syntax

Thanks !

lamdawr avatar Mar 16 '18 14:03 lamdawr

could you add a line in caffe_model1.py

from __future__ import print_function

and try if it works?

kitstar avatar Mar 17 '18 08:03 kitstar

Thank you very much for the reply. But I got the following error after adding the line from future import print_function :

Traceback (most recent call last): File "caffe_model1.py", line 98, in gen_weight(args.weight_file, args.model, args.prototxt) File "caffe_model1.py", line 72, in gen_weight net = caffe.Net(prototxt, caffe.TRAIN) Boost.Python.ArgumentError: Python argument types in Net.init(Net, unicode, int) did not match C++ signature: init(boost::python::api::object, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, int) init(boost::python::api::object, std::__cxx11::basic_string<char, std::char_traits, std::allocator > network_file, int phase, int level=0, boost::python::api::object stages=None, boost::python::api::object weights=None)

lamdawr avatar Mar 19 '18 13:03 lamdawr

hi @lamdawr , Could you share some files for us to reproduce? Thanks.

kitstar avatar Mar 19 '18 14:03 kitstar

Hi @kitstar , what files would you like ?

lamdawr avatar Mar 19 '18 14:03 lamdawr

The code and models of source framework would be fine. And you can post the caffe_model1.py for quick check. Thanks.

kitstar avatar Mar 19 '18 14:03 kitstar

Traceback (most recent call last): File "caffe_model1.py", line 98, in gen_weight(args.weight_file, args.model, args.prototxt) File "caffe_model1.py", line 72, in gen_weight net = caffe.Net(prototxt, caffe.TRAIN) Boost.Python.ArgumentError: Python argument types in Net.init(Net, unicode, int) did not match C++ signature: init(boost::python::api::object, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, int) init(boost::python::api::object, std::__cxx11::basic_string<char, std::char_traits, std::allocator > network_file, int phase, int level=0, boost::python::api::object stages=None, boost::python::api::object weights=None)

This issue can be solved by converting the filenames from unicode to string, i.e. caffe.Net(str(prototxt), caffe.TRAIN)

galli-leo avatar Mar 20 '18 16:03 galli-leo

Fixed in last commit. Thanks!

kitstar avatar Mar 22 '18 08:03 kitstar

@kitstar Actually, that doesn't work, since the save method also expects a string (and not unicode). I have a fix in my local install, which I can commit with the other caffe emitter changes.

galli-leo avatar Mar 22 '18 08:03 galli-leo