dusty-nv / jetson-inference

Hello AI World guide to deploying deep-learning inference networks and deep vision primitives with TensorRT and NVIDIA Jetson.
https://developer.nvidia.com/embedded/twodaystoademo
MIT License
7.75k stars 2.97k forks source link

How to convert data into BCHW format #1807

Closed lofyol closed 6 months ago

lofyol commented 6 months ago

Thank you for the great work of the author. After resizing with jetson_utils, how do I convert the HWC format to BCHW format data?

dusty-nv commented 6 months ago

Hi @lofyol , this is done with the kernels in c/tensorConvert.cu, although these aren't usually exposed API's:

https://github.com/dusty-nv/jetson-inference/blob/master/c/tensorConvert.cu

lofyol commented 6 months ago

@dusty-nv Thank you. Is there a conversion interface for python?

dusty-nv commented 6 months ago

No, I don't expose those to python: you could try torch.as_tensor() and just do it in PyTorch:

https://github.com/dusty-nv/jetson-inference/blob/master/docs/aux-image.md#cuda-array-interface

lofyol commented 6 months ago

OK,thank you~