Skip to content

Latest commit

 

History

History

tf_saved_models

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Usage

  1. Put frozen models into ./frozen directory
  2. Add serving information in export_serving_model.py
    • Set update messages UPDATE_MESSAGE
    • Define a export function
    • Put @ServingInfo.export decorator on export function(if not, then this model will not export)
  3. Run export_serving_model.py
  4. Copy the serving model ./serving/{version} to your serving model directory on the server

Note

Run script export_serving_model.py will automaticly generate(or modify) two files under directory ./serving:

  • current_version: Stores the current version and update information. See details.
  • exported_models: Exported models, one model for one line.

Test

You don't need to konwn what the hyaudio model is. We just use it to demonstrate the export functionality.

We will export the same model two times to simulate the simultaneous export multiple models.

When you export multiple models, you should specify the

  • signature_name
  • input_signature_map
  • output_signature_map

parameters. They refer to signature for serving, entry point of the model and output point of the model respectively.

model signature_name input_signature_map output_signature_map frozen location(./frozen)
[model description] hyaudio_1 'inputs':'hyaudio/vggish_input:0' 'classes':'hyaudio/predict_classes:0', 'probs':'hyaudio/predict_probs:0' audio/hyaudio.pb
[model description] hyaudio_2 'inputs':'hyaudio/vggish_input:0' 'classes':'hyaudio/predict_classes:0', 'probs':'hyaudio/predict_probs:0' audio/hyaudio.pb

Check the serving model

We use the SavedModel CLI tool to check our exported models.

To show all available SignatureDef keys in a MetaGraphDef.

saved_model_cli show --dir ./serving/1 --tag_set serve

To show all inputs and outputs TensorInfo for a specific SignatureDef, pass in the SignatureDef key to signature_def option. This is very useful when you want to know the tensor key value, dtype and shape of the input tensors for executing the computation graph later.

saved_model_cli show --dir ./serving/1 --tag_set serve --signature_def hyaudio_1