How to convert channel last keras model into channel first ONNX model

1.7k views Asked by At

I want to convert keras .h5 model into ONNX model. But my model is trained channel last and I want it channel first. I found that there is an argument in keras2onnx.convert_keras called channel_first_inputs but couldn't find any example on how to use it on their official site.

I am doing this step as a part of the process of converting my keras model into .engine model. Is there any other way to do so without the need to onnx intermediate step?.


Searching for the parameter name inside the keras2onnx code, I found the following usage

  • In Here: channel_first_inputs=['input_1']
  • In Here: channel_first_inputs=[model.input_names[0]]
1

There are 1 answers

0
Fadwa On BEST ANSWER

I used channel_first_inputs=['input_1'] and it worked fine.