Closed ElectroMonk closed 1 week ago
It is safe to ignore errors of less than 1e-4
for (Unmatched)
. Therefore, the model transformation is completely successful when the error in the final output output
is zero (Matches)
.
onnx2tf -i Unet.onnx -cotof -oiqt
The reason why the inference accuracy seems to deteriorate significantly when you use the generated model is because there is a bug in the logic you wrote. There are already a large number of similar issues reported in the issue tracker, so please search the issue tracker carefully.
Issue Type
Others
OS
Linux
onnx2tf version number
1.26.1
onnx version number
1.17.0
onnxruntime version number
1.19.2
onnxsim (onnx_simplifier) version number
0.4.36
tensorflow version number
2.17.0
Download URL for ONNX
https://drive.google.com/file/d/1PwK_DwBY2DP3jo-Z19mqgKTK6mOcVKE2/view
Parameter Replacement JSON
Description
hello I'm trying to convert a Unet to Int8. The encoding in Float32 and Float16 works, as well as the daýnamic quatiesation. But I would like to use the quatiesation with Int8 and Int32 (integer_quant or full_integer_quant). The accuracy of the TFLite integer_quant models drops dramatically and can no longer be used. I get a unmatched of three layers, probably the error is here. Unfortunately, I'm not quite sure how to use the Replacement JSON, I tried specifying Replacement JSON file.
When I inspect the integer_qunat TFLite with Netron it is worth mentioning that the biasis of the last layers are almost dead. Would be great if someone could help me and thanks in advance! The complete output is down below.
logs
``` onnx2tf -cotof -i Unet.onnx -o UNetTFL -oiqt Model optimizing started ============================================================ Simplifying... Finish! Here is the difference: ┏━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ ┃ ┃ Original Model ┃ Simplified Model ┃ ┡━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ │ Concat │ 4 │ 4 │ │ Constant │ 46 │ 46 │ │ Conv │ 19 │ 19 │ │ ConvTranspose │ 4 │ 4 │ │ MaxPool │ 4 │ 4 │ │ Relu │ 18 │ 18 │ │ Sigmoid │ 1 │ 1 │ │ Model Size │ 29.6MiB │ 29.6MiB │ └───────────────┴────────────────┴──────────────────┘ Simplifying... Finish! Here is the difference: ┏━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ ┃ ┃ Original Model ┃ Simplified Model ┃ ┡━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ │ Concat │ 4 │ 4 │ │ Constant │ 46 │ 46 │ │ Conv │ 19 │ 19 │ │ ConvTranspose │ 4 │ 4 │ │ MaxPool │ 4 │ 4 │ │ Relu │ 18 │ 18 │ │ Sigmoid │ 1 │ 1 │ │ Model Size │ 29.6MiB │ 29.6MiB │ └───────────────┴────────────────┴──────────────────┘ Simplifying... Finish! Here is the difference: ┏━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ ┃ ┃ Original Model ┃ Simplified Model ┃ ┡━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ │ Concat │ 4 │ 4 │ │ Constant │ 46 │ 46 │ │ Conv │ 19 │ 19 │ │ ConvTranspose │ 4 │ 4 │ │ MaxPool │ 4 │ 4 │ │ Relu │ 18 │ 18 │ │ Sigmoid │ 1 │ 1 │ │ Model Size │ 29.6MiB │ 29.6MiB │ └───────────────┴────────────────┴──────────────────┘ Model optimizing complete! Automatic generation of each OP name started ======================================== Automatic generation of each OP name complete! Model loaded ======================================================================== Model conversion started ============================================================ INFO: input_op_name: input shape: [1, 3, 256, 256] dtype: float32 INFO: 2 / 51 INFO: onnx_op_type: Conv onnx_op_name: wa/encoder1/enc1conv1/Conv INFO: input_name.1: input shape: [1, 3, 256, 256] dtype: float32 INFO: input_name.2: onnx::Conv_188 shape: [32, 3, 3, 3] dtype: float32 INFO: input_name.3: onnx::Conv_189 shape: [32] dtype: float32 INFO: output_name.1: wa/encoder1/enc1conv1/Conv_output_0 shape: [1, 32, 256, 256] dtype: float32 INFO: tf_op_type: convolution_v2 INFO: input.1.input: name: input shape: (1, 256, 256, 3) dtype: