Open Z68bakh opened 5 years ago
How did you generate the ONNX model you are using? The error indicates the model file is missing the opset version, which is required
The onnx model is generated by converting scikit learn SVC model to onnx:
loaded_model = pickle.load(open('svc.pkl', 'rb')) # svc is the model I had already
initial_type = [('float_input', FloatTensorType([1, 4]))] onx = convert_sklearn(loaded_model, initial_types=initial_type, target_opset=9) with open("loaded_model.onnx", "wb") as f: f.write(onx.SerializeToString())
model = onnx.load('loaded_model.onnx') model.ir_version=4
onnx.save(model, 'model_new.onnx')
onnx_model = onnx.load('model_new.onnx')
print('The model is:\n{}'.format(onnx_model))
Check the model
onnx.checker.check_model(onnx_model) print('The model is checked!')
And the model is checked.
You do not have to set "model.ir_version=4". The converter will take care of it. (make sure you are using latest version)
Caffe2 does not support models converted from scikitlearn. You should use ONNX Runtime instead.
I am trying to convert an onnx model to caffe2 but I got the following error:
I have checked the backend.py and it seems that there is something wrong with model.ir_version, it is always None.
Is anyone facing the same issue? Any idea how to solve it?