We’re compiling a segmentation model from SavedModel (.pb) to .hef.
The SavedModel performs well while the .hef returns many detections around the actual object that should be detected.
We used the conversion code once (when the model was trained with 20k images) and it worked. Now the model is trained with more than 200k images and we are facing the mentioned issue.
By the way, the SavedModel performs well with TensorFlow.
It seems like there might be some discrepancies between the training data, preprocessing steps, or conversion settings that are causing the model to perform differently than expected.
Here are a few steps we recommend to help troubleshoot and resolve the problem:
Double check that the input data for the HEF model during inference is being preprocessed in exactly the same way as the training data and when you tested the SavedModel in TensorFlow. Even small differences in input shape, normalization, or augmentations can throw things off.
With the larger 200k image dataset, it’s possible the model may have started to overfit or learn spurious patterns. Take a look at the model’s performance on a validation set to assess how well it’s generalizing. Comparing some feature maps from the TensorFlow and HEF models could also shed light on where they start to diverge.
Review the parameters used when converting the SavedModel to HEF, like the quantization settings and input scaling. Minor differences there can lead to unexpected output. Make sure to provide a representative calibration dataset during compilation so the quantization is tuned properly for your use case.
Let me know if this helps !
if you have any other questions! We’re here to help.
thanks for the answer. Unfortunately the issue is still present. However, we investigated all the steps during the conversion and we noticed that the problem arises during quantization.
Indeed, original .har performs well while the quantized does not.
Moreover, we tried to tune the parameters in the script but the results never change. We do not see any difference in the output, no matter how we change such parameters.
For the calibration we use 8192 images and we verified that the normalization is the same as used for training. The normalization in performed externally to the model.