0

I am using a pre-trained keras based and tensorflow based model with yolov2 architecture for potholes detection and I'm getting an error while converting my tensorflow model to tensorflow lite

from tensorflow.contrib import lite

converter = lite.TFLiteConverter.from_keras_model_file( 'model.h5' )
model = converter.convert()
file = open( 'model.tflite' , 'wb' )
file.write( model )
desertnaut
  • 57,590
  • 26
  • 140
  • 166
gadrion
  • 31
  • 1
  • 2
  • Do you know whether there are any custom_ops and/or controlflow ops in your model? I would suggest you to use TF2.x with `converter = tf.compat.v1.lite.TFLiteConverter.from_keras_model_file( 'model.h5' ), converter.experimental_new_converter = True`. Check [TF_website](https://www.tensorflow.org/lite/performance/post_training_integer_quant) for examples. – Vishnuvardhan Janapati Apr 13 '20 at 18:25
  • Thx for the quick reply! Unfortunately, that didn't work. I get the same error :( – gadrion Apr 13 '20 at 21:57
  • If you can share the model file, I can help. Finding root-cause is difficult without looking into the model. Thanks – Vishnuvardhan Janapati Apr 13 '20 at 22:32
  • Sure! https://drive.google.com/open?id=1VwViHDdc4W8t28rMiuGjxChiAtFxMAjN – gadrion Apr 14 '20 at 04:17

1 Answers1

0

I would suggest going for a longer but tested path.

1) Convert your model directly as .pb frozen graph format or convert from h5 to .pb using How to export Keras .h5 to tensorflow .pb?

2) Convert .pb to tflite as described by me here: https://medium.com/@prashantdandriyal7/darknet-to-tensorflow-to-tensorflowlite-b783d55b106a

Pe Dro
  • 2,651
  • 3
  • 24
  • 44