keras-onnx
keras-onnx copied to clipboard
hi,I use keras2onnx to transfer keras_based network,then transfer onnx to tensorrt.when parsing with tensorrt,error shows like:netwokr layers=0!do you know why is it?
code like this: from keras.models import load_model model = load_model('logs/multiBands/testKeras/last1.hdf5' )
onnx_model = keras2onnx.convert_keras(model, model.name) temp_model_file = 'conv_hdf5.onnx' onnx.save_model(onnx_model, temp_model_file)
Is the onnx model itself working? If it does, then it should not be keras2onnx issue.
can you show me how to prove the onnx model itself is working?
Is the onnx model itself working? If it does, then it should not be keras2onnx issue.
can you show me how to prove the onnx model itself is working?
We have many examples in our tests, does the onnx model run successfully using onnxruntime?
We have many examples in our tests, does the onnx model run successfully using onnxruntime?
I put a png named 00003.png and run run_image in test_utils.py like this,but the output in NONE,Are you sure what the problem is?
from keras.applications.resnet50 import ResNet50 model = ResNet50(include_top=True, weights='imagenet') run_image(model,'./logs','./00003.png')
We have many examples in our tests, does the onnx model run successfully using onnxruntime?
or can you show me the details for running the examples in tests?
test_utils is the utility file. In applications/nightly_build, there are many examples there. Many are computer vision related models.
test_utilsis the utility file. Inapplications/nightly_build, there are many examples there. Many are computer vision related models.
I run test_deeplab_v3.py in applications/nightly_build,the output is like this: Ran 1 test in 0.009s OK (skipped=1) Skipped: DeeplabV3 is not supported for opset < 11.
is it normal?
This is probably because you are using old onnx package. Try onnx==1.7.0. You can also set target_opset=12 in convert_keras function.
Here is an example for ResNet50.
This is probably because you are using old onnx package. Try
onnx==1.7.0. You can also settarget_opset=12inconvert_kerasfunction.Here is an example for ResNet50.
I have installed onnx 1.7.0,and run ResNet50,the output is like this: Ran 8 tests in 0.004s OK (skipped=8) Skipped: Tensorflow 2.x only tests Skipped: Tensorflow 2.x only tests Skipped: Tensorflow 2.x only tests Skipped: Tensorflow 2.x only tests Skipped: Tensorflow 2.x only tests Skipped: Tensorflow 2.x only tests Skipped: Tensorflow 2.x only tests Skipped: Tensorflow 2.x only tests
so this output can prove keras2onnx itself is normal, parse onnxmodel transfored using tensorrt but get network.layer=0 is another ploblem?
This is probably because you are using old onnx package. Try
onnx==1.7.0. You can also settarget_opset=12inconvert_kerasfunction.Here is an example for ResNet50.
use keras2onnx.convert_keras function to transfer model,the output is: The ONNX operator number change on the optimization: 450 -> 122 I1229 11:51:59.263113 10340 topology.py:348] The ONNX operator number change on the optimization: 450 -> 122
From the log, the onnx model looks good. Do you transfer to tensorrt through https://github.com/onnx/onnx-tensorrt ? If so, you can raise an issue there.
From the log, the onnx model looks good. Do you transfer to tensorrt through https://github.com/onnx/onnx-tensorrt ? If so, you can raise an issue there.
ok,I will try to raise an issue there.But I want to ensure that the onnx model is correct.By the way,I use netron to see the onnx model,there will be a transpose layer which is not in model.Dose onnx only support channel_first?when the model is channle_last,is it transposed to the channel_first shape by automatically adding transposed layer?
Yes, it adds Transpose layer as you said.
Yes, it adds Transpose layer as you said.
Will it affect the parse process using tensorrt?The worst situation,I mean,lead to parsing failed?
No, the parse process should put no assumption on the onnx model.