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

TypeError: expected bytes, str found #32

Open
duys3416 opened this issue Dec 12, 2018 · 3 comments
Open

TypeError: expected bytes, str found #32

duys3416 opened this issue Dec 12, 2018 · 3 comments

Comments

@duys3416
Copy link

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.

@2401ch
Copy link

2401ch commented Jan 16, 2019

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

@look-recognize
Copy link

same problem

@Yang507
Copy link

Yang507 commented Mar 14, 2020

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')

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

4 participants