caffe-tensorflow
caffe-tensorflow copied to clipboard
text.split error
When I run convert.py, I got some trouble which is following
File "C:/Caffe/caffe/python/caffe2tensorflow/convert.py", line 61, in
To solve this trouble, I change : text.split('\n') -> text.split('\n'.encode()) but also have some trouble
File "C:\Users\User\Anaconda3\lib\site-packages\google\protobuf\text_format.py", line 474, in Merge text.split('\n'.encode()), TypeError: Can't convert 'bytes' object to str implicitly
please someone can help my problem, thanx
I am experiencing this as well. Did you happen to find a solution? I am on Windows 10 with Anaconda.
I also use Anaconda3 on Windows10, but I did not solve this problem yet.
I just tested this on an AWS linux machine. The issue also happens when using Python 3. When using Python 2, it works. Unfortunately on Windows though, we can only use TensorFlow with Python 3.
In kaffe\graph.py:
def load(self): '''Load the layer definitions from the prototxt.''' self.params = get_caffe_resolver().NetParameter() with open(self.def_path, 'rb') as def_file: text_format.Merge(def_file.read(), self.params)
change the 'rb' to 'r'.
I think it should help
@ohadlights fix leads to the following error for me:
$ ./convert.py examples/mnist/lenet.prototxt --code-output-path=mynet.py
Traceback (most recent call last):
File "./convert.py", line 60, in <module>
main()
File "./convert.py", line 56, in main
args.phase)
File "./convert.py", line 27, in convert
transformer = TensorFlowTransformer(def_path, caffemodel_path, phase=phase)
File "/home/kevin/Deadpool/Convert/caffe-tensorflow-master/kaffe/tensorflow/transformer.py", line 221, in __init__
self.load(def_path, data_path, phase)
File "/home/kevin/Deadpool/Convert/caffe-tensorflow-master/kaffe/tensorflow/transformer.py", line 254, in load
print_stderr(self.graph)
File "/home/kevin/Deadpool/Convert/caffe-tensorflow-master/kaffe/errors.py", line 7, in print_stderr
sys.stderr.write('%s\n' % msg)
File "/home/kevin/Deadpool/Convert/caffe-tensorflow-master/kaffe/graph.py", line 125, in __str__
tuple(out_shape)))
TypeError: unsupported format string passed to tuple.__format__
May be this solution may help you fix.. First, you should use Linux such as Ubuntu 16.04 Then, you can use conda to create and control the env.
In this case
conda create -n caffe-tf python=2 tensorflow caffe
source activate caffe-tf
Hope it helps
If you have such a problem using different Python versions or using Windows consider running it with Docker:
https://github.com/nicolov/segmentation_keras/tree/master/conversion https://github.com/ivanzhovannik/convert_caffe_windows
@johnsrude I am facing the same problem, do u have any solutions now?