Hope following may help you.
For example, if the input is an image, you could use a python script like this:
import PIL.Image
import numpy as np
im = PIL.Image.open(“input_image.jpg”).resize((512, 512))
data = np.asarray(im, dtype=np.float32)
data.tofile(“input_tensor.dat”)
This will “convert” an image to that .dat file which is basically just a raw binary buffer of datatype fp32.Or if it’s not an image, whatever other data source you use, just load it with numpy, cast it to the correct datatype and shape that TensorRT expects to use as input (usually but not always float32) and write it out with numpy’s .tofile() function as above.Then on trtexec, you can load it like this: