Error in pre-processing of the test_images

hii @nvidias

I am trying to load an classification engine model in python script and pass an image directory which contains sub-folders (sub-folders are different classes) after running the script getting error:
Traceback (most recent call last):
File “infer_resnet18_classification.py”, line 116, in
test_case = load_normalized_test_case(test_image, h_input)
File “infer_resnet18_classification.py”, line 59, in load_normalized_test_case
np.copyto(pagelocked_buffer, normalize_image(Image.open(test_image)))
File “infer_resnet18_classification.py”, line 50, in normalize_image
image_arr = np.asarray(image.resize((w, h), Image.ANTIALIAS)).transpose([2, 0, 1]) .astype(trt.nptype(trt.float32)).ravel()
ValueError: axes don’t match array

I am attaching my scrip here
infer_resnet18_classification.py (5.0 KB)
Any help will be appreciable
thanks

Please check if your images are 1 channel or 3 channels.

@Morganh hii
my images are of 3 channels.
what should I implement?
thanks

First, make sure TensorRT/samples/python/introductory_parser_samples at master · NVIDIA/TensorRT · GitHub can run successfully against your images.

1 Like

@Morganh
link which you have shared here I can pass .engine model instead of uff and onxx?

Refer to Inferring resnet18 classification etlt model with python - #12 by Morganh

@Morganh hey … thanks
able to run it.