Description
New Operator
Describe the operator
Convolution2DTransposeBias
Do you know this operator be constructed using existing ONNX operators?
I do not know much about ONNX operators, but there's an old ticket that (if I'm reading it correctly) indicates that was supposed to be supported a few years ago via this ticket: #1740
Is this operator used by any model currently? Which one?
https://ai.google.dev/edge/mediapipe/solutions/vision/image_segmenter#selfie-model
Are you willing to contribute it? (Y/N)
No
Notes
I apologize in advance if I explain this poorly or if there's pilot error on my part; this is all outside of my normal skillset.
We were able to successfully use tf2onnx several years to convert an early mediapipe model and integrate it into our Java desktop application. It's always been functional-but-mediocre in quality, and now we're trying to see if updates are available to make it more accurate. That tflite file is no longer available/supported, and it looks like we're supposed to use the selfie-model referenced above.
When I try to convert it on my Mac, here is what I see in my Terminal:
jeremy@Jeremys-MacBook-Pro ~ % pip3 install onnx
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Collecting onnx
Using cached onnx-1.17.0-cp39-cp39-macosx_12_0_universal2.whl.metadata (16 kB)
Requirement already satisfied: numpy>=1.20 in /usr/local/lib/python3.9/site-packages (from onnx) (1.22.3)
Requirement already satisfied: protobuf>=3.20.2 in /usr/local/lib/python3.9/site-packages (from onnx) (3.20.3)
Using cached onnx-1.17.0-cp39-cp39-macosx_12_0_universal2.whl (16.6 MB)
Installing collected packages: onnx
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Successfully installed onnx-1.17.0
jeremy@Jeremys-MacBook-Pro ~ % pip3 install tf2onnx
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Collecting tf2onnx
Using cached tf2onnx-1.16.1-py3-none-any.whl.metadata (1.3 kB)
Requirement already satisfied: numpy>=1.14.1 in /usr/local/lib/python3.9/site-packages (from tf2onnx) (1.22.3)
Requirement already satisfied: onnx>=1.4.1 in /usr/local/lib/python3.9/site-packages (from tf2onnx) (1.17.0)
Requirement already satisfied: requests in /usr/local/lib/python3.9/site-packages (from tf2onnx) (2.27.1)
Requirement already satisfied: six in /usr/local/lib/python3.9/site-packages (from tf2onnx) (1.16.0)
Collecting flatbuffers>=1.12 (from tf2onnx)
Using cached flatbuffers-25.2.10-py2.py3-none-any.whl.metadata (875 bytes)
Requirement already satisfied: protobuf~=3.20 in /usr/local/lib/python3.9/site-packages (from tf2onnx) (3.20.3)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.9/site-packages (from requests->tf2onnx) (1.26.9)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.9/site-packages (from requests->tf2onnx) (2021.10.8)
Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.9/site-packages (from requests->tf2onnx) (2.0.12)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.9/site-packages (from requests->tf2onnx) (3.3)
Using cached tf2onnx-1.16.1-py3-none-any.whl (455 kB)
Using cached flatbuffers-25.2.10-py2.py3-none-any.whl (30 kB)
Installing collected packages: flatbuffers, tf2onnx
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Successfully installed flatbuffers-25.2.10 tf2onnx-1.16.1
jeremy@Jeremys-MacBook-Pro ~ % python3 -m tf2onnx.convert --tflite /Users/jeremy/Downloads/selfie_segmenter_landscape.tflite --output /Users/jeremy/Downloads/selfie_segmenter_landscape.onnx
2025-04-12 00:58:50.924324: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
/usr/local/Cellar/[email protected]/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py:127: RuntimeWarning: 'tf2onnx.convert' found in sys.modules after import of package 'tf2onnx', but prior to execution of 'tf2onnx.convert'; this may result in unpredictable behaviour
warn(RuntimeWarning(msg))
2025-04-12 00:58:53,358 - INFO - Using tensorflow=2.13.0, onnx=1.17.0, tf2onnx=1.16.1/15c810
2025-04-12 00:58:53,358 - INFO - Using opset <onnx, 15>
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
2025-04-12 00:58:53,371 - WARNING - Error loading model into tflite interpreter: Encountered unresolved custom op: Convolution2DTransposeBias.
See instructions: https://www.tensorflow.org/lite/guide/ops_custom Node number 244 (Convolution2DTransposeBias) failed to prepare.Encountered unresolved custom op: Convolution2DTransposeBias.
See instructions: https://www.tensorflow.org/lite/guide/ops_custom Node number 244 (Convolution2DTransposeBias) failed to prepare.
2025-04-12 00:58:53,439 - WARNING - Could not parse attributes for custom op 'TFL_Convolution2DTransposeBias': 0
2025-04-12 00:58:53,593 - ERROR - Tensorflow op [conv2d_transpose: TFL_Convolution2DTransposeBias] is not supported
2025-04-12 00:58:53,593 - ERROR - Unsupported ops: Counter({'TFL_Convolution2DTransposeBias': 1})
2025-04-12 00:58:53,606 - INFO - Optimizing ONNX model
2025-04-12 00:58:54,621 - INFO - After optimization: Cast -110 (110->0), Const -20 (140->120), GlobalAveragePool +5 (0->5), Identity -1 (1->0), ReduceMean -5 (10->5), Reshape +13 (11->24), Transpose -197 (222->25)
2025-04-12 00:58:54,633 - INFO -
2025-04-12 00:58:54,633 - INFO - Successfully converted TensorFlow model /Users/jeremy/Downloads/selfie_segmenter_landscape.tflite to ONNX
2025-04-12 00:58:54,634 - INFO - Model inputs: ['input_1']
2025-04-12 00:58:54,634 - INFO - Model outputs: ['segment_back']
2025-04-12 00:58:54,634 - INFO - ONNX model is saved at /Users/jeremy/Downloads/selfie_segmenter_landscape.onnx
At this point I was prepared to report to my team that this is simply not supported, but the existence of #1779 makes me think this may (?) be possible if someone smarter than me has a look.
(I encountered similar errors about "hard swishes" in my earliest attempts, but I think those were resolved simply by updating the opset.)