Skip to content

Can not parse the caffe2 pretrain model. google.protobuf.message.DecodeError: Error parsing message #62699

Open
@WangFengtu1996

Description

@WangFengtu1996

🐛 Bug

  • I have a very stupid request, to parse the caffe2 pretrain model. I try to install the caffe2 from source code, but I can get any code.
  • I try to import caffe2 related python package, I successed.
    image
  • I try to parse the pretrain model under the doc
            data_type = onnx.TensorProto.FLOAT
            input_tensor_shape = self.input_nodes.split(':')[-1]
            n,c,w,h = input_tensor_shape.replace(')', '').replace('(','').split(',')
            input_name = self.input_nodes.split(':')[0]
            input_spec = (int(n), int(c), int(w), int(h))
            value_info = {
                input_name : (data_type,input_spec)
            }
            predict_net = caffe2_pb2.NetDef()
            with open(os.path.join(self.input_file,'predict_net.pb'), 'rb') as f:
                predict_net.ParseFromString(f.read())
            init_net = caffe2_pb2.NetDef()
            with open(os.path.join(self.input_file,'init_net.pb'), 'rb') as f:
                 init_net.ParseFromString(f.read())
            onnx_model = caffe2.python.onnx.frontend.caffe2_net_to_onnx_model(
                predict_net,
                init_net,
                value_info,
            )

            onnx.save(onnx_model, os.path.join(self.output_path, self.input_file.split('/')[-1] + "_caffe2.onnx"))
  • I got the error
    image

  • I must to use the caffe2 framework, would you give me some guide?

Environment

  • PyTorch Version 1.9.0
  • OS (e.g., Linux): ubuntu 18.04
  • How you installed PyTorch (conda, pip, source): pip
  • Build command you used (if compiling from source):
  • Python version: 3.7.10
  • CUDA/cuDNN version: 10.2
  • GPU models and configuration:
  • Any other relevant information:

Activity

added
triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
on Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    caffe2triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Can not parse the caffe2 pretrain model. google.protobuf.message.DecodeError: Error parsing message · Issue #62699 · pytorch/pytorch