Skip to content

Commit

Permalink
SavedModel TF Serve Fix (ultralytics#7228)
Browse files Browse the repository at this point in the history
* SavedModel TF Serve Fix

Fix for ultralytics#7205 proposed by @tylertroy

* Update export.py
  • Loading branch information
glenn-jocher committed Mar 31, 2022
1 parent 99f410f commit 7aed800
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions export.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,12 @@ def export_saved_model(model,
if keras:
keras_model.save(f, save_format='tf')
else:
m = tf.function(lambda x: keras_model(x)) # full model
spec = tf.TensorSpec(keras_model.inputs[0].shape, keras_model.inputs[0].dtype)
m = tf.function(lambda x: keras_model(x)) # full model
m = m.get_concrete_function(spec)
frozen_func = convert_variables_to_constants_v2(m)
tfm = tf.Module()
tfm.__call__ = tf.function(lambda x: frozen_func(x)[0], [spec])
tfm.__call__ = tf.function(lambda x: frozen_func(x)[:4] if tf_nms else frozen_func(x)[0], [spec])
tfm.__call__(im)
tf.saved_model.save(tfm,
f,
Expand Down

0 comments on commit 7aed800

Please sign in to comment.