Part-IV : Convert Keras Model to TensorFlow SavedModel Format

4 Part blog series : Documenting the learnings of my experimentation on Object Detection using Keras, Tensorflow

Karan Singh
2 min readMar 28, 2021

In the last blog post, we will learn how to convert a keras model file into a TensorFlow (2.x) frozen graph model format (*.pb) and its text representation (*.pbtxt) .

In this blog post we will learn to convert the same keras model file into TensorFlow SavedModel format *.pb

Introduction

TF Saved Model Format : A single SavedModel may represent multiple graph definitions as MetaGraphDef protocol buffers. Weights and other variables usually aren’t stored inside the file during training. Instead, they’re held in separate checkpoint files

Implementation

If you like to follow along, refer to 4_convert_keras_model_to_tensorflow_savedmodel_format.ipynb jupyter notebook from my repository. Below are the implementation steps, the following program loads up keras model files and convert that to tensorflow SavedModel format *.pb

  • Once keras model is converted to TF SavedModel format, list the models directory. Here you will find saved_model.pb model file as well as assets and variables directories. Assets contains external files and variables is a subfolder that includes output from tf.train.Saver
  • Finally, let’s use this newly created TensorFlow SavedModel file and try to do inferencing (detect license plate)
  • You should get results like below

Summary

  • In this blog, we have learned how to converted keras h5 model file to tensorflow SavedModel format
  • We have validated that the newly created TF SavedModel works by detecting license plate from input image

--

--

Karan Singh

Co-Founder & CTO @ Scogo ♦ I Love to solve problems using Tech