Skip to content

Commit 4381b2b

Browse files
authored
Merge pull request #1000 from jignparm/jignparm/servetag
Make 'serve' tag default again.
2 parents 011cf5e + 7498113 commit 4381b2b

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

tf2onnx/tf_loader.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,16 @@ def from_checkpoint(model_path, input_names, output_names):
181181
def _from_saved_model_v1(sess, model_path, input_names, output_names, tag, signatures):
182182
"""Load tensorflow graph from saved_model."""
183183

184+
wrn_no_tag = "'--tag' not specified for saved_model. Using --tag serve"
185+
wrn_empty_tag = "'--tag' value is empty string. Using tag =[[]]"
186+
184187
if tag is None:
185188
tag = [tf.saved_model.tag_constants.SERVING]
189+
logger.warning(wrn_no_tag)
190+
191+
if tag == '':
192+
tag = [[]]
193+
logger.warning(wrn_empty_tag)
186194

187195
if not isinstance(tag, list):
188196
tag = [tag]
@@ -218,7 +226,8 @@ def _from_saved_model_v1(sess, model_path, input_names, output_names, tag, signa
218226
def _from_saved_model_v2(model_path, input_names, output_names, tag, signature_def, concrete_function_index):
219227
"""Load tensorflow graph from saved_model."""
220228

221-
wrn_no_tag = "'--tag' not specified for saved_model. Using empty tag [[]]"
229+
wrn_no_tag = "'--tag' not specified for saved_model. Using --tag serve"
230+
wrn_empty_tag = "'--tag' value is empty string. Using tag =[[]]"
222231
wrn_sig_1 = "'--signature_def' not specified, using first signature: %s"
223232
err_many_sig = "Cannot load multiple signature defs in TF2.x: %s"
224233
err_no_call = "Model doesn't contain usable concrete functions under __call__. Try --signature-def instead."
@@ -227,8 +236,13 @@ def _from_saved_model_v2(model_path, input_names, output_names, tag, signature_d
227236
err_sig_nomatch = "Specified signature not in model %s"
228237

229238
if tag is None:
230-
tag = [[]]
239+
tag = ['serve']
231240
logger.warning(wrn_no_tag)
241+
242+
if tag == '':
243+
tag = [[]]
244+
logger.warning(wrn_empty_tag)
245+
232246
utils.make_sure(len(signature_def) < 2, err_many_sig, str(signature_def))
233247
imported = tf.saved_model.load(model_path, tags=tag) # pylint: disable=no-value-for-parameter
234248

0 commit comments

Comments
 (0)