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

Trouble Converting IR to Caffe #111

Closed
lamdawr opened this issue Mar 16, 2018 · 8 comments
Closed

Trouble Converting IR to Caffe #111

lamdawr opened this issue Mar 16, 2018 · 8 comments
Assignees

Comments

@lamdawr
Copy link

lamdawr commented Mar 16, 2018

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 !

@kitstar
Copy link
Contributor

kitstar commented Mar 17, 2018

could you add a line in caffe_model1.py

from __future__ import print_function

and try if it works?

@lamdawr
Copy link
Author

lamdawr commented Mar 19, 2018

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)

@kitstar
Copy link
Contributor

kitstar commented Mar 19, 2018

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

@lamdawr
Copy link
Author

lamdawr commented Mar 19, 2018

Hi @kitstar , what files would you like ?

@kitstar
Copy link
Contributor

kitstar commented Mar 19, 2018

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

@kitstar kitstar assigned msftgits and TobeyQin and unassigned msftgits Mar 19, 2018
@galli-leo
Copy link
Contributor

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)

@kitstar
Copy link
Contributor

kitstar commented Mar 22, 2018

Fixed in last commit. Thanks!

@kitstar kitstar closed this as completed Mar 22, 2018
@galli-leo
Copy link
Contributor

galli-leo commented Mar 22, 2018

@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.

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