1

I'm trying to convert a YOLOv5 model to a TFLite model for mobile devices, but I'm having issues with the generated file. The TFLite model is so large in size and is giving completely wrong predictions compared to the original YOLOv5 model. the original YOLOv5s file is ~13.7 while the TFLite model is ~26.9, I converted it as follows:

!python export.py --weights best.pt --include tflite --img 640 --data data.yaml 

and then:

converter = tf.lite.TFLiteConverter.from_saved_model('best_saved_model')
tflite_model = converter.convert()

with open('model.tflite', 'wb') as f:
  f.write(tflite_model)

Can anyone provide guidance on how to convert a YOLOv5 model to TFLite properly and ensure that the predictions are accurate? Any help would be greatly appreciated!

  • Hi @Fatema. Did you get a solution to this? My model is also giving wrong results when I convert it to tflite – Andrew Sithole Apr 18 '23 at 16:11
  • @AndrewSithole unfortunately no, but while searching i found this if it may be of use https://stackoverflow.com/questions/68722909/yolov4-to-tflite-model-giving-completely-wrong-predictions – Fatema Shawki Apr 19 '23 at 13:58

0 Answers0