Open
Description
🐛 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.
- 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"))
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