Trouble Converting IR to Caffe
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 !
could you add a line in caffe_model1.py
from __future__ import print_function
and try if it works?
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
hi @lamdawr , Could you share some files for us to reproduce? Thanks.
Hi @kitstar , what files would you like ?
The code and models of source framework would be fine. And you can post the caffe_model1.py for quick check. Thanks.
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)
Fixed in last commit. Thanks!
@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.