Skip to main content Link Search Menu Expand Document (external link)

@mlswapch attribute

:electric_plug: dp.kinect3 dp.oak
:information_source: signature
mlswapch BOOLEAN
:house: values
no swap
swap input channels 0 and 2 before inference
:bulb: examples
@mlswapch 1

Swap 3-channel ml input tensor channels 0 and 2 before inference.

:memo: @mlinput may be easier to understand than @mlswapch.

Most models that process color data need their input in a specific channel order. @mlswapch is one method to change the order of channels. For example, RGB color frames with @mlswapch 1 will swap channels 0 and 2 to make BGR for inference.

+-----+                           +-----+  
| RGB |   -->  @mlswapch 1  -->   | BGR |
+-----+                           +-----+

3-channel input with @mlswapch applies @mlmean and @mlscale to channels 2,1,0 and swaps data channels 0 and 2 before sending to the model as input.