Morganh
February 10, 2021, 7:11am
41
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()
1 Like
Hi @Morganh ,
Thank you so much… It worked… The results are now same with tlt-infer and standalone script…
@jazeel.jk hii
hey after running your script on my classification model I am getting one class always and also 0 positive negative values like this .
Any idea?
Thanks
@senbhaskar26 ,
Yes, that script was made for testing my model… i had 2 classes “positive” and “negative”… you can edit with the name of your classes…
1 Like
thanks got it working for my model. @jazeel.jk
have you tried in which you can get the accuracy at last where you can check the total accuracy of your model for all different classes.
2 Likes