Skip to content

CombinedNonMaxSuppression is not supported in ONNX #1337

@jan-golda

Description

@jan-golda

Describe the bug
I am trying to convert MaskRCNN in TensorFlow 2 to ONNX but it is failing due to CombinedNonMaxSuppression op being not supported in ONNX.

Urgency
It is blocking the use of MaskRCNN in ONNX.

System information

  • OS Platform and Distribution: Linux Ubuntu 20.04.1
  • Tensorflow Version: 2.3.1
  • ONNX version: 1.8.0
  • Python version: 3.8.5

To Reproduce
Try to convert any model that uses tf.image.combined_non_max_suppression

Expected behaviour
A model should be converted without a fail on CombinedNonMaxSuppression op.

Additional context
This was already reported in #847 for YOLO, and I have tried to apply the workaround from there - replace CombinedNonMaxSuppression with a NonMaxSuppression accompanied by a set of ops that were meant to replace the "Combined" part.

I have tried to get it to work for a few days, but in the case of MaskRCNN, this seems to be more complicated than in the case of YOLO. I had to apply the NonMaxSuppression for each class in each sample from batch separately, then pad it, select the top results for a class, then select the top results for a box, retrieve information about classes and scores, pad it again and finally gather results across the batch.

There is a reason why this op was added to TF, as recreating it from scratch is quite complicated, therefore I would like to ask if you could add the support for it in the ONNX.

Moreover, when I was running the model with partially applied changes I was observing significant performance drop when running it with automatic mixed-precision - in short: replacing the CombinedNonMaxSuppression has a noticeable impact on the original TF model, which is not ideal.

Metadata

Metadata

Labels

pending on user responseWaiting for more information or validation from user

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions