Tensorflow Image Classification model with Triplet Loss accuracy drops when is transtated to TensorRT on JetsonNano

Hi I have created a DL model using transfer learning and Triplet Loss, the base model is EfficienNetB0 with tensorflow. I have trained the model to generate embeddings from car images with the goal to recognize images from a car taken from different cameras, computing the euclidean distance between those embeddings.
To translate the model to TensorRT I’m using TF-TRT.

This is the structure of my model in TensorFlow:

model = Sequential([
data_augmentation,
layers.Lambda(preprocess_input, name=‘preprocessing’, input_shape=(img_width,img_height,3)),
efnet,
layers.GlobalAveragePooling2D(),
layers.Dense(128, activation=None),
layers.Dropout(0.3),
layers.Lambda(lambda x: tf.math.l2_normalize(x, axis=1)) # L2 normalize embeddings
])

An this is how I prepare the tensor linked to the image to be evaluated by TensorRT model:
from tensorflow.keras.applications.efficientnet import preprocess_input

def load_image(img_path, show=False):

img = ImageKeras.load_img(img_path, target_size=(180, 180))
img_tensor = ImageKeras.img_to_array(img)                    # (height, width, channels)
img_tensor = np.expand_dims(img_tensor, axis=0)        
img_tensor = preprocess_input(img_tensor)

return tf.constant(img_tensor)

I have a couple of test with images from cars taken from different cameras, and when computing the distance between those vectors that represent images, the closest ones should be from the same car.
In Tensorflow I have achieved an accuracy for one test case of 88%, which drops to 79% on the Jetson.
Moreover, in another test case, with Tensorflow I have achieved an accuracy of 86% which decreases to 80% on the Jetson.
I’m working with precision FP32.

I’m performing the conversion and inference inside a docker container with base image:
nvcr.io/nvidia/l4t-tensorflow:r32.4.4-tf2.3-py3

I look forward for your answers, I have been stuck with this for a couple of days.
Best Regards,
Valentina.

Hi, Request you to share the model and script so that we can try reproducing the issue at our end.

Also we recommend you to check the below samples links, as they might answer your concern

Thanks!

Here is a zip with the model, the script for conversion to TensoRT, the scripts for evaluation, the dataset of test images. I look forward for your answer.
Best Regards,
Valentina.NVIDIA.zip (22.0 MB)

Hi @maria.dasilva,

This looks like jetson issue. Could you please post your query on related forum.

Thank you.