Support TFLite and TFJS conversion for CenterNet multi-class keypoints #11101
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Rewrote the
_postprocess_keypoints_multi_class()
method incenter_net_meta_arch.py
to not usetf.tensor_scatter_nd_add
ops, which seem to:TensorScatterAdd
is not supported).This is a non-breaking change: The model's outputs in the exported SavedModel format remain 100% unchanged after this rewrite. Additionally, no negative impact on latency was observed - my tests yielded a latency improvement of ~3%:
For this reason, I replaced the code in the existing
_postprocess_keypoints_multi_class()
method. However, please let me know if I should leave that method as-is and add a new one instead.Type of change
Tests
Besides the unit test added in this PR, I ran tests to ensure that the TFLite and TFJS models run successfully without crashing, as well as to test outputs and latency of SavedModels. I have uploaded the models and Python scripts in the drive link below:
https://drive.google.com/drive/folders/1wCUvu_LQN6maRQFAKkAU8l1JnsOYm_-F?usp=sharing
Test Configuration: The scripts were ran in Python 3.10.13 and Tensorflow 2.8.1/2.14.0.
Checklist