How to infer more than one image (batch size > 1)

Hi all, I want to know how the existing sample code can be modified to infer with batch size more than 1.
In the existing sample code from the directory
/usr/src/tensorrt/samples/python/network_api_pytorch_mnist/sample.py and model.py
the inference on gpu will be done with only one image (784, ). which is obtained by calling the method
img, expected_output = model.get_random_testcase()
It will return the tensor with shape(784, )
784 is 28 * 28 which is the size of only one image.
I want to know how I can modify the existing code for doing inference with batch size more than 1. Please let me know.

Thanks and Regards

Nagaraj Trivedi

Dear @trivedi.nagaraj,
Could you confirm if the platform is Jetson Nano or Jetson Orin Nano?

I see the sample is using EXPLICIT_BATCH . Did you check with INPUT_SHAPE = (2, 1, 28, 28) in sample.py for batchsize 2?

Hi SivaRamaKrishnan, it is for the Jetson Nano.
I will try what you have suggested.

Thanks and Regards

Nagaraj Trivedi

It worked. Thank you for your suggestion.

Thanks and Regards

Nagaraj Trivedi

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.