Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noisy inference results with TF2 int8 tflite models #637

Closed
Rahn80643 opened this issue Apr 25, 2022 · 9 comments
Closed

Noisy inference results with TF2 int8 tflite models #637

Rahn80643 opened this issue Apr 25, 2022 · 9 comments
Labels
Bug Something isn't working Question Further information is requested

Comments

@Rahn80643
Copy link

Rahn80643 commented Apr 25, 2022

Hi,

I'm migrating our segmentation model from TensorFlow1 to TensorFlow2, and the model is retrained with TensorFlow quantization aware training technique; however, the inference results of TF2 tflite model from ArmNN are not ideal, the comparisons and environment settings are shown below:

armnn2202_1

armnn2202_2

  • ArmNN 22.02
  • Compute Library 22.02
  • FlatBuffers 1.12.0
  • Protobuf 3.12.0
  • TensorFlow 2.4.0

Based on the inference results from TensorFlow tflite API, the weights in tflite models seems normal, but the inference results from ArmNN contain many noisy pixels, I want to ask:

  1. Is this issue resulted from the version of TensorFlow or tflite?
  2. How to effectively improve the inference results in ArmNN?

Best Regards,
Rahn

@TeresaARM
Copy link
Collaborator

Hi @Rahn80643,

thank you very much for your comment. which backend are you using when you run ArmNN, CpuAcc, GpuAcc or CpuRef?

@Rahn80643
Copy link
Author

Hi @TeresaARM,

I've tested with CpuAcc and GpuAcc backend, and the inference results are similar

@TeresaARM
Copy link
Collaborator

TeresaARM commented Apr 26, 2022

Hi @Rahn80643,

could you give it a go to CpuRef? and see if the results are closer to TensorFlow? The performance will be worse than CpuAcc and GpuAcc, as CpuRef is just a "reference", but this information will help us to find out where the issue is.

Thank you!

@Rahn80643
Copy link
Author

Hi @TeresaARM,

The followings are the inference results using CpuRef, and the results are not closer to those from TensorFlow

armnn2202_1

armnn2202_2

Thank you

@Rahn80643
Copy link
Author

Hi,

I compared two int8 tflite models trained in TensorFlow1 and TensorFlow2 respectively, and I found the input zero point values are different. Is this the main reason why inferring TensorFlow2 int8 tflite model generates noisy results? If so, how to include the input zero point into ArmNN inference code to solve this issue?

zero_point

Rahn

@MatthewARM
Copy link
Collaborator

yes, this could be the problem. In your application code, when you convert the input image into a tensor for Arm NN, are you taking the zero-point into account?

@MatthewARM
Copy link
Collaborator

If this is the problem, there is some good explanation of it here: #161

@Rahn80643
Copy link
Author

Hi,

I've tried the following modifications but the inference results still contain noisy results:

  1. Based on thread #161, the author had tried not to do preprocess the image and divide the output by 255. I tried the same process in ArmNN; however, since the values of output results are within the range of [0, 255], if the values are divided by 255, the results will be all 0s.

  2. the input images are preprocessed based on the following formula in ArmNN,
    new_value = ((old_value/scale_factor) - mean)/ stddev. Therefore, I've tried changing mean values, but the inference results still contain noisy results:

different mean values

Apart from modifying the mean values in preprocess stage, are there other approaches to take the zero-point into account in ArmNN settings?

@keidav01 keidav01 added Bug Something isn't working Question Further information is requested labels Oct 5, 2022
@morgolock
Copy link
Collaborator

I'm closing this due to inactivity, if you require support please reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants