Please modify the preprocessing. It will fix the issue. The standalone inference result will be the same as tlt-infer. Main change is that ‘RGB’->‘BGR’ and Zero-center by mean pixel.
Add below.
from keras.applications.imagenet_utils import preprocess_input
And change
return np.asarray(image.resize((w, h), Image.ANTIALIAS)).transpose([2, 0, 1]).astype(trt.nptype(trt.float32)).ravel()
to
return preprocess_input(np.asarray(image.resize((w, h), Image.ANTIALIAS)).transpose([2, 0, 1]).astype(trt.nptype(trt.float32)), mode=‘caffe’, data_format=‘channels_first’).ravel()