starimeL/PytorchConverter

TypeError: expected bytes, str found

Opened this issue · 3 comments

Hi, I want know which is your protobuf version? and I use python3.5 and protobuf 3.0.0 but meet error like:

text_net, binary_weights = ConvertModel_caffe(pytorch_net, InputShape, softmax=False)
File "/home/ysdu/PytorchConverter/code/ConvertModel.py", line 318, in ConvertModel_caffe
import caffe_pb2 as pb2
File "/home/ysdu/PytorchConverter/code/caffe_pb2.py", line 17, in
serialized_pb='\n\x0b\x63\x61\x66\x66\x65.proto\x12\x05\x63\x61\x66\x66\x65"\x1c\n\tBlobShape
.........
.........
File "/home/xxx/.local/lib/python3.5/site-packages/google/protobuf/descriptor.py", line 827, in new
return _message.default_pool.AddSerializedFile(serialized_pb)
TypeError: expected bytes, str found

Thanks.

Have you solved this problem? I met it too, and did not know how to deal with it.

same problem

modify:

          #add
          import sys
         _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
          #modified
          serialized_pb=_b('\n\x0b\xo...)
          _b('\020\001')
          _b("constant").decode('utf-8')