tflite model has bad accuracy
Hi @codingzebra333  !
 I tried to replicate the issue on Colab using TF v2.11 but facing a different error. Could you please provide dependencies to reproduce the issue and find the gist [here](https://colab.research.google.com/gist/tiruk007/b23c955476d80be16eed766de5ba2c8f/untitled122.ipynb) for reference.

Thank you!
 Hey, 
Thank you for fast response! [ Here ](https://colab.research.google.com/drive/14zMCm0XaszVrUoWd9bMvBjSXSdPvSWuw?userstoinvite=tirumaleshk%40google.com&actionButton=1#scrollTo=t-P2l2a-9AOm) is a colab file.
I also tested .h5 file and .tflite on a different dataset (400 images) and compared the results:
- .tflite vs .h5 (images that are in a good quality)
MAD: 1.8
RMSE: 1.9
- tflite vs .h5 (same images but in a bad quality)
MAD: 0.3
RMSE: 0.4
Tflite model evaluates good images and bad images pretty much in the same way. 
 @pjpratik 
 
I was able to reproduce the issue on Colab using TFv2.11. please find the gist [here](https://colab.research.google.com/gist/tiruk007/bcd8c781bbe3a2ab376fdb90cd342d8d/untitled132.ipynb) for reference.

Thank you! @codingzebra333 Sorry for the delayed response. 

I did try to reproduce the .csv file but facing some error while creating the model. Please find the [gist](https://colab.research.google.com/gist/pjpratik/1db27191830e15d4540b2984484b0983/59684.ipynb). 

The conversion seems to be fine in both the cases.  Also, the error difference from what is [reported](https://github.com/tensorflow/tensorflow/issues/59684#issuecomment-1431121144), specifically for good quality images seems to be on bit higher side.

The quantization aware training is supposed to give better model accuracy than post training quantization. Please refer to [document](https://www.tensorflow.org/model_optimization/guide/quantization/training) for QAT and let us know if it helps.

Thanks.

 Hi, thank you for your response! 
If the conversion is fine in both cases, how come the model is unusable because of the terrible accuracy? Post training quantization is supposed to reduce the model accuracy by a little - not make it unusable. Is it because of the model architecture or is there any other possible explanation to this?
Also, what other solutions would you suggest without having to re-train all models? 
Regarding the errors, you just need to change from "from backbone.resnet50 import ResNet50" to "from triq.src.backbone.resnet50 import ResNet50" - it can't find a model because the path is incorrect.
Thank you in advance! Hi @codingzebra333 

I have tested the both tflite model and .h5 model on the sample data provided. The results are
```
For 2.9 MOS
tflite = 2.8592536100477446
.h5= 2.906168824993074

For 2.865 MOS
tflite=2.880292271496728
.h5= 2.742017399519682
```
What I see is that tflite results are not bad compared to the MOS infact tflite results are closer than .h5 in second case.
Please find the gist [here](https://colab.research.google.com/gist/pjpratik/934d2e4f087fd8ac484d3faac3c72b1f/59684.ipynb).  I feel it is acceptable but depends on the use case.

Can you please let us know your observation regarding the same?

 Hey, as I mentioned before, I tested it out on a different dataset with 400 images - good and bad quality. I provided the MAD and RMSE scores before. Tflite model evaluates good images and bad images pretty much in the same way. 
[Here](https://drive.google.com/drive/folders/1YcCSJgG6R4wRJ5qeU3gUoUd2296GghoL?usp=sharing) is a dataset available for comparison. First MOS score in image name is .h5 result and second one is .tflite result. 

 Hey, are there any updates regarding this?  Hey, is there anything new regarding this? Hi, is there anyone who can help me with this?  Hi @codingzebra333, can you please share an up to date colab which reproduces the results, including the dataset (or where I can get the dataset) mentioned here, please also include the unconverted and converted model:

>I also tested .h5 file and .tflite on a different dataset (400 images) and compared the results:

>.tflite vs .h5 (images that are in a good quality)
>MAD: 1.8
>RMSE: 1.9
>tflite vs .h5 (same images but in a bad quality)
>MAD: 0.3
>RMSE: 0.4
>Tflite model evaluates good images and bad images pretty much in the same way.

Thanks for helping us refresh this issue. This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/59684">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/59684">No</a>

Hey, 
I used tflite converter to convert .h5 file, the model is much smaller than the original, but the accuracy dropped drastically.[ Here ](https://colab.research.google.com/drive/14zMCm0XaszVrUoWd9bMvBjSXSdPvSWuw?userstoinvite=tirumaleshk%40google.com&actionButton=1#scrollTo=JWvOm1R5WyPs )is the code. Could you please check if everything is correct?
Thank you in advance!