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.all_util import remove_undocumented 23from tensorflow.python.util.tf_export import tf_export 24 25 26# Key in the signature def map for `default` serving signatures. The default 27# signature is used in inference requests where a specific signature was not 28# specified. 29DEFAULT_SERVING_SIGNATURE_DEF_KEY = "serving_default" 30tf_export("saved_model.signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY" 31 ).export_constant(__name__, "DEFAULT_SERVING_SIGNATURE_DEF_KEY") 32 33################################################################################ 34# Classification API constants. 35 36# Classification inputs. 37CLASSIFY_INPUTS = "inputs" 38tf_export("saved_model.signature_constants.CLASSIFY_INPUTS").export_constant( 39 __name__, "CLASSIFY_INPUTS") 40 41# Classification method name used in a SignatureDef. 42CLASSIFY_METHOD_NAME = "tensorflow/serving/classify" 43tf_export( 44 "saved_model.signature_constants.CLASSIFY_METHOD_NAME").export_constant( 45 __name__, "CLASSIFY_METHOD_NAME") 46 47# Classification classes output. 48CLASSIFY_OUTPUT_CLASSES = "classes" 49tf_export( 50 "saved_model.signature_constants.CLASSIFY_OUTPUT_CLASSES").export_constant( 51 __name__, "CLASSIFY_OUTPUT_CLASSES") 52 53# Classification scores output. 54CLASSIFY_OUTPUT_SCORES = "scores" 55tf_export( 56 "saved_model.signature_constants.CLASSIFY_OUTPUT_SCORES").export_constant( 57 __name__, "CLASSIFY_OUTPUT_SCORES") 58 59################################################################################ 60# Prediction API constants. 61 62# Predict inputs. 63PREDICT_INPUTS = "inputs" 64tf_export("saved_model.signature_constants.PREDICT_INPUTS").export_constant( 65 __name__, "PREDICT_INPUTS") 66 67# Prediction method name used in a SignatureDef. 68PREDICT_METHOD_NAME = "tensorflow/serving/predict" 69tf_export( 70 "saved_model.signature_constants.PREDICT_METHOD_NAME").export_constant( 71 __name__, "PREDICT_METHOD_NAME") 72 73# Predict outputs. 74PREDICT_OUTPUTS = "outputs" 75tf_export("saved_model.signature_constants.PREDICT_OUTPUTS").export_constant( 76 __name__, "PREDICT_OUTPUTS") 77 78################################################################################ 79# Regression API constants. 80 81# Regression inputs. 82REGRESS_INPUTS = "inputs" 83tf_export("saved_model.signature_constants.REGRESS_INPUTS").export_constant( 84 __name__, "REGRESS_INPUTS") 85 86# Regression method name used in a SignatureDef. 87REGRESS_METHOD_NAME = "tensorflow/serving/regress" 88tf_export( 89 "saved_model.signature_constants.REGRESS_METHOD_NAME").export_constant( 90 __name__, "REGRESS_METHOD_NAME") 91 92# Regression outputs. 93REGRESS_OUTPUTS = "outputs" 94tf_export("saved_model.signature_constants.REGRESS_OUTPUTS").export_constant( 95 __name__, "REGRESS_OUTPUTS") 96 97################################################################################ 98 99 100_allowed_symbols = [ 101 "DEFAULT_SERVING_SIGNATURE_DEF_KEY", 102 "CLASSIFY_INPUTS", 103 "CLASSIFY_METHOD_NAME", 104 "CLASSIFY_OUTPUT_CLASSES", 105 "CLASSIFY_OUTPUT_SCORES", 106 "PREDICT_INPUTS", 107 "PREDICT_METHOD_NAME", 108 "PREDICT_OUTPUTS", 109 "REGRESS_INPUTS", 110 "REGRESS_METHOD_NAME", 111 "REGRESS_OUTPUTS", 112] 113remove_undocumented(__name__, _allowed_symbols) 114