2

While deserializing onnx binary I am getting following error:

Traceback (most recent call last):
 from model.ParseFromString(f.read())
 File "~/protobuf-3.3.0-py2.7.egg/google/protobuf/message.py", line 185, in ParseFromString
 self.MergeFromString(serialized)
 File "~/protobuf-3.3.0-py2.7.egg/google/protobuf/internal/python_message.py", line 1063, in MergeFromString
 if self._InternalParse(serialized, 0, length) != length:
 File "~/protobuf-3.3.0-py2.7.egg/google/protobuf/internal/python_message.py", line 1099, in InternalParse
 pos = field_decoder(buffer, new_pos, end, self, field_dict)
 File "~/protobuf-3.3.0-py2.7.egg/google/protobuf/internal/decoder.py", line 615, in DecodeRepeatedField
 raise _DecodeError('Unexpected end-group tag.')
 google.protobuf.message.DecodeError: Unexpected end-group tag.

I am using protobuf version 3.3.0. I am using ParseFromString function which gives the error.

Can anybody please help me on how to handle this error?

valiano
  • 16,433
  • 7
  • 64
  • 79
  • does your payload validate cleanly here: https://protogen.marcgravell.com/decode ? if that site *also* says you have an unexpected end-group tag, then: you probably have an unexpected end-group tag - which means: your data is corrupt. So: where did the data come from? has it been treated as text at some point? (protobuf is not text; treating it as text will corrupt it) can you perhaps post the hex or base-64 of the payload here? does your schema even use groups? note: another common possible cause of corruption is overwriting a file with *less* data without truncating it (trailing garbage). – Marc Gravell Apr 02 '20 at 13:57
  • I am using https://github.com/onnx/models/blob/master/vision/body_analysis/emotion_ferplus/model/emotion-ferplus-2.onnx file – user2033594 Apr 02 '20 at 14:01
  • I'm not familiar with onnx - is that the raw protobuf binary payload? – Marc Gravell Apr 02 '20 at 14:07
  • I am using import proto3_pb2 f = open(sys.argv[1],"rb") model = proto3_pb2.ModelProto() model.ParseFromString(f.read()) f.close() graph = model.graph print(graph.node) . This reads the onnx binary – user2033594 Apr 02 '20 at 14:11
  • I tried with protobuf 3.5.2 and it was working. Is there a bug in this version. If yes, if there a way I can solve without switching to this version – user2033594 Apr 02 '20 at 14:15
  • I'm going to hazard a guess at "no, you'll need to use the version that works" – Marc Gravell Apr 02 '20 at 14:21
  • @MarcGravell can u give it a try with protobuf 3.3.0. If it works at your end. – user2033594 Apr 02 '20 at 14:24

0 Answers0