Closed CarlosNacher closed 5 months ago
Your model contains a normalization layer, so you should not normalize the quantization calibration data. In addition, input data should not be normalized during inference. All of the above. I also answered this in my last issue.
Duplicate of https://github.com/PINTO0309/onnx2tf/issues/607 Duplicate of https://github.com/PINTO0309/onnx2tf/issues/611
Your model contains a normalization layer, so you should not normalize the quantization calibration data. In addition, input data should not be normalized during inference. All of the above. I also answered this in my last issue.
I dont't which type of normalization are Sub-Div, and I don't understand that my model could have a normalization layer, since I created the model from scratch and it hadn't norm layer. I created my model in torch, and always passed the input previuosly preprocessing it (resize + norm / 255 and imagenet's mean and std), then I exported my model to onnx and tried the inference, also always previously preprocessing it and thus with the keras model returned by onnx2tf.convert
(preprocessing it). So, why now in tflite model shouldn't I do it? and why you say it has norm layer?
I am pretty sure it needs that preprocessing, because besides, when I use the scale_factor
and zero_point
stored in interpreter.get_input_details()[0]
to normalize my preprocessed data, it converts to -127, 127 range, and if not preprocessed it takes strange values. So, I think preprocessing is okay and then I don't know why the integer quantized model returns always same value :/
Thank you in advance.
Duplicate of #607 Duplicate of #611
Oh, does that mean that if my onnx file is the same I should continue responding in the same initial issue even if the main topic is not the same? I opened another issues to try to keep different topics independent, but if I should do it in another way, please let me know to follow best practices and accept my apologies if I have done it wrong.
Issue Type
Others
OS
Windows
onnx2tf version number
1.19.16
onnx version number
1.15.0
onnxruntime version number
1.17.1
onnxsim (onnx_simplifier) version number
0.4.33
tensorflow version number
2.15.0
Download URL for ONNX
https://we.tl/t-HJjXDINMND
Parameter Replacement JSON
Description
When I try full integer quantization, the inference always return the same value, that is, the quantized model is losing all the accuracy and I don't know why. It has to be one reason / one thing I am not doing properly, because if it will lose some accuracy it would be understandable, but always return the same value is not normal.
Have you any idea of what could be happening? :/ Thank you so much for your library!!
My code:
DATA I AM USING FOR CALIB AND ALSO FOR TRYING INFERENCE (
pre_processed_input
): https://we.tl/t-FhSDHicE4v and the preprocessing is resizing to 1024, 608 and normalizing / 255The
tflite_inference
has the same repeated value (0.006) :/