Equivalent of caffe's transformer.set_transpose(layer_name, (2,0,1)) with Cuda/Jetson-inference examples

I’m trying to port over a caffe model from Python & Caffe to the Jetson tx2 with TensorRT.

This model does gaze estimation.

You can see a collobaratory notebook here with it working:
https://colab.research.google.com/drive/11s5IQkI8H-kIn00Kg6Sqp-dD3RwsICdE

I’m following the examples in jetson-inference which are super helpful. One thing I’m wondering, is that in the python/caffe code, there is a step that does:

transformer = caffe.io.Transformer({layer_name: net.blobs['data'].data.shape})
transformer.set_transpose(layer_name, (2,0,1))  # move image channels to outermost dimension
transformer.set_mean(layer_name, mean_image)            # subtract the dataset-mean value in each channel

How can I do this in the context of the jetson-inference examples in c++?

Does the function cudaPreImageNetMean take care of moving image channels to the outermost dimension?

Hi,

In jetson_inferece, channel conversion and mean subtraction is handled by CUDA kernel.
Check here for the source code:
https://github.com/dusty-nv/jetson-inference/blob/master/imageNet.cu#L96

Thanks.