onnx转化为caffe2 pb文件
import caffe2.python.onnx.backend as cf2_backend
from onnx_caffe2.backend import Caffe2Backend as cf2_backend2
cf2_rep = cf2_backend.prepare(model)
output = cf2_rep.run(np_onnx_image.astype(np.float32))
same = True if id2class[np.argmax(output)] == label else False
print(same)
init_net, predict_net = cf2_backend2.onnx_graph_to_caffe2_net(model.graph)
with open("./ONNX/Mobilenet_init_net.pb", "wb") as f:
f.write(init_net.SerializeToString())
with open("./ONNX/Mobilenet_predict_net.pb", "wb") as f:
f.write(predict_net.SerializeToString())