glenn-jocher commited on
Commit
734ab03
1 Parent(s): 4d157f5

SavedModel TF Serve Fix (#7228)

Browse files

* SavedModel TF Serve Fix

Fix for https://github.com/ultralytics/yolov5/issues/7205 proposed by

@tylertroy



* Update export.py

Files changed (1) hide show
  1. export.py +2 -2
export.py CHANGED
@@ -285,12 +285,12 @@ def export_saved_model(model,
285
  if keras:
286
  keras_model.save(f, save_format='tf')
287
  else:
288
- m = tf.function(lambda x: keras_model(x)) # full model
289
  spec = tf.TensorSpec(keras_model.inputs[0].shape, keras_model.inputs[0].dtype)
 
290
  m = m.get_concrete_function(spec)
291
  frozen_func = convert_variables_to_constants_v2(m)
292
  tfm = tf.Module()
293
- tfm.__call__ = tf.function(lambda x: frozen_func(x)[0], [spec])
294
  tfm.__call__(im)
295
  tf.saved_model.save(tfm,
296
  f,
 
285
  if keras:
286
  keras_model.save(f, save_format='tf')
287
  else:
 
288
  spec = tf.TensorSpec(keras_model.inputs[0].shape, keras_model.inputs[0].dtype)
289
+ m = tf.function(lambda x: keras_model(x)) # full model
290
  m = m.get_concrete_function(spec)
291
  frozen_func = convert_variables_to_constants_v2(m)
292
  tfm = tf.Module()
293
+ tfm.__call__ = tf.function(lambda x: frozen_func(x)[:4] if tf_nms else frozen_func(x)[0], [spec])
294
  tfm.__call__(im)
295
  tf.saved_model.save(tfm,
296
  f,