-
-
Notifications
You must be signed in to change notification settings - Fork 15.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SavedModel TF Serve Fix #7228
SavedModel TF Serve Fix #7228
Conversation
Fix for #7205 proposed by @tylertroy
@tylertroy your proposed fix breaks existing workflows, i.e. SavedModel inference with detect.py: !git clone https://github.com/ultralytics/yolov5 -b fix/tf_serve
%cd yolov5
!python export.py --include saved_model
!python detect.py --weights yolov5s_saved_model EDIT: Since all TF exports rely on SavedModel as a prerequisite they are all probably also impacted. So this small change has knockon impacts down the export and inference workflows that would need to be resolved for before update could be considered for merging with master. |
@glenn-jocher As I understand it, any time the Edit: Now I understand the issue you describe. Perhaps an if statement can clear this up. diff --git a/export.py b/export.py
index 7517dc4..0c44cc0 100644
--- a/export.py
+++ b/export.py
@@ -276,7 +276,7 @@ def export_saved_model(model, im, file, dynamic,
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], [spec]) if tf_nms else tf.function(lambda x: frozen_func(x)[0], [spec])
tfm.__call__(im)
tf.saved_model.save(
tfm, |
@tylertroy yes it's true that NMS models are no longer detect.py compatible. It seems like the proposed update (or at least my implementation here) affects SavedModels regardless of the --nms flag though. Maybe the solution is an |
@glenn-jocher |
@tylertroy PR is merged. Thank you for your contributions to YOLOv5 π and Vision AI β |
* SavedModel TF Serve Fix Fix for ultralytics#7205 proposed by @tylertroy * Update export.py
Fix for #7205 proposed by @tylertroy
π οΈ PR Summary
Made with β€οΈ by Ultralytics Actions
π Summary
Enhanced TensorFlow SavedModel export functionality with NMS (Non-Max Suppression) support.
π Key Changes
π― Purpose & Impact