How to convert HDF5 files into tflite files

After we train the model with keras, we usually save the model format type as hdf5, that is. H5 file.

But if we want to migrate to the mobile end, especially the one supported by tensorflow, we need to convert it to tflite.

How to convert? In tensorflow1.9 and above versions, it is convenient to convert by command line.

tflite_convert --output_file=/home/yourname/Documents/tensorflow/images/500pics2/model/my_model.tflite --keras_model_file=/home/yourname/Documents/tensorflow/images/500pics2/model/my_model.h5

Other options are available at https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/toco/g3doc/cmdLine_examples.md#keras

 

  

Leave a Reply

Your email address will not be published. Required fields are marked *