keras2onnx遇到的错误

1、安装pip install keras2onnx
首先要注意,python文件千万别命名为keras2onnx.py
执行python k2o.py ,然后遇到下面错误
Using TensorFlow backend.
Traceback (most recent call last):
File “k2o.py”, line 2, in
import keras2onnx
File “/usr/local/lib/python3.6/dist-packages/keras2onnx-1.6.5-py3.6.egg/keras2onnx/ke2onnx/init.py”, line 6, in
File “

2、出现错误

----------------------------------------------------------------
Input filename:   /home/mllabs4/xmjws/class_tf/model_k.onnx
ONNX IR version:  0.0.6
Opset version:    11
Producer name:    keras2onnx
Producer version: 1.6.5
Domain:           onnx
Model version:    0
Doc string:       
----------------------------------------------------------------

[02/25/2020-15:29:58] [W] [TRT] onnx2trt_utils.cpp:198: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
[02/25/2020-15:29:58] [W] [TRT] onnx2trt_utils.cpp:198: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
terminate called after throwing an instance of 'std::out_of_range'
  what():  Attribute not found: pads
Aborted (core dumped)

这个查了好久,发现是onnx的Opset version导致的,
我之前用的11,改成10就可以,需要进行下面修改:
onnx_model = keras2onnx.convert_keras(model, model.name, target_opset=10)

你可能感兴趣的:(keras2onnx遇到的错误)