microsoft / onnxruntime-extensions

onnxruntime-extensions: A specialized pre- and post- processing library for ONNX Runtime
MIT License
295 stars 80 forks source link

How to drop a channel using onnxruntime-extensions? #668

Open ani-mal opened 3 months ago

ani-mal commented 3 months ago

Description

Hi, I am trying to add several pre-processing steps to the ComputerVision onnx I am working on. I was able to add almost all the pre and post-processing steps I wanted, but now I want to solve the case where the input image has an alpha channel.

So the original model expects [ batch, 3, width, height ], but the application I am working on deals with images that have an alpha channel [ batch, 4, width, height ].

How can I go about adding a pre-processing step inside the onnx model that would be able to drop the alpha channel?

Thank you for your help :)

wenbingl commented 3 months ago

there are two ONNX operator split/concat to split the channel dimension and then concat the 3 channels that you want. https://onnx.ai/onnx/operators/onnx__Split.html