1# Copyright 2016 The TensorFlow Authors. All Rights Reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# ============================================================================== 15"""Signature constants for SavedModel save and restore operations. 16 17""" 18from __future__ import absolute_import 19from __future__ import division 20from __future__ import print_function 21 22from tensorflow.python.util.tf_export import tf_export 23 24 25# Key in the signature def map for `default` serving signatures. The default 26# signature is used in inference requests where a specific signature was not 27# specified. 28DEFAULT_SERVING_SIGNATURE_DEF_KEY = "serving_default" 29tf_export( 30 "saved_model.DEFAULT_SERVING_SIGNATURE_DEF_KEY", 31 v1=[ 32 "saved_model.DEFAULT_SERVING_SIGNATURE_DEF_KEY", 33 "saved_model.signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY" 34 ], 35).export_constant(__name__, "DEFAULT_SERVING_SIGNATURE_DEF_KEY") 36 37################################################################################ 38# Classification API constants. 39 40# Classification inputs. 41CLASSIFY_INPUTS = "inputs" 42tf_export( 43 "saved_model.CLASSIFY_INPUTS", 44 v1=[ 45 "saved_model.CLASSIFY_INPUTS", 46 "saved_model.signature_constants.CLASSIFY_INPUTS" 47 ]).export_constant(__name__, "CLASSIFY_INPUTS") 48 49# Classification method name used in a SignatureDef. 50CLASSIFY_METHOD_NAME = "tensorflow/serving/classify" 51tf_export( 52 "saved_model.CLASSIFY_METHOD_NAME", 53 v1=[ 54 "saved_model.CLASSIFY_METHOD_NAME", 55 "saved_model.signature_constants.CLASSIFY_METHOD_NAME" 56 ]).export_constant(__name__, "CLASSIFY_METHOD_NAME") 57 58# Classification classes output. 59CLASSIFY_OUTPUT_CLASSES = "classes" 60tf_export( 61 "saved_model.CLASSIFY_OUTPUT_CLASSES", 62 v1=[ 63 "saved_model.CLASSIFY_OUTPUT_CLASSES", 64 "saved_model.signature_constants.CLASSIFY_OUTPUT_CLASSES" 65 ]).export_constant(__name__, "CLASSIFY_OUTPUT_CLASSES") 66 67# Classification scores output. 68CLASSIFY_OUTPUT_SCORES = "scores" 69tf_export( 70 "saved_model.CLASSIFY_OUTPUT_SCORES", 71 v1=[ 72 "saved_model.CLASSIFY_OUTPUT_SCORES", 73 "saved_model.signature_constants.CLASSIFY_OUTPUT_SCORES" 74 ]).export_constant(__name__, "CLASSIFY_OUTPUT_SCORES") 75 76################################################################################ 77# Prediction API constants. 78 79# Predict inputs. 80PREDICT_INPUTS = "inputs" 81tf_export( 82 "saved_model.PREDICT_INPUTS", 83 v1=[ 84 "saved_model.PREDICT_INPUTS", 85 "saved_model.signature_constants.PREDICT_INPUTS" 86 ]).export_constant(__name__, "PREDICT_INPUTS") 87 88# Prediction method name used in a SignatureDef. 89PREDICT_METHOD_NAME = "tensorflow/serving/predict" 90tf_export( 91 "saved_model.PREDICT_METHOD_NAME", 92 v1=[ 93 "saved_model.PREDICT_METHOD_NAME", 94 "saved_model.signature_constants.PREDICT_METHOD_NAME" 95 ]).export_constant(__name__, "PREDICT_METHOD_NAME") 96 97# Predict outputs. 98PREDICT_OUTPUTS = "outputs" 99tf_export( 100 "saved_model.PREDICT_OUTPUTS", 101 v1=[ 102 "saved_model.PREDICT_OUTPUTS", 103 "saved_model.signature_constants.PREDICT_OUTPUTS" 104 ]).export_constant(__name__, "PREDICT_OUTPUTS") 105 106################################################################################ 107# Regression API constants. 108 109# Regression inputs. 110REGRESS_INPUTS = "inputs" 111tf_export( 112 "saved_model.REGRESS_INPUTS", 113 v1=[ 114 "saved_model.REGRESS_INPUTS", 115 "saved_model.signature_constants.REGRESS_INPUTS" 116 ]).export_constant(__name__, "REGRESS_INPUTS") 117 118# Regression method name used in a SignatureDef. 119REGRESS_METHOD_NAME = "tensorflow/serving/regress" 120tf_export( 121 "saved_model.REGRESS_METHOD_NAME", 122 v1=[ 123 "saved_model.REGRESS_METHOD_NAME", 124 "saved_model.signature_constants.REGRESS_METHOD_NAME" 125 ]).export_constant(__name__, "REGRESS_METHOD_NAME") 126 127# Regression outputs. 128REGRESS_OUTPUTS = "outputs" 129tf_export( 130 "saved_model.REGRESS_OUTPUTS", 131 v1=[ 132 "saved_model.REGRESS_OUTPUTS", 133 "saved_model.signature_constants.REGRESS_OUTPUTS" 134 ]).export_constant(__name__, "REGRESS_OUTPUTS") 135 136################################################################################ 137# Train/Eval API constants. 138# Not exported while export_all_saved_models is experimental. 139DEFAULT_TRAIN_SIGNATURE_DEF_KEY = "train" 140 141DEFAULT_EVAL_SIGNATURE_DEF_KEY = "eval" 142 143SUPERVISED_TRAIN_METHOD_NAME = "tensorflow/supervised/training" 144 145SUPERVISED_EVAL_METHOD_NAME = "tensorflow/supervised/eval" 146