onnx2tf: [MMVC]Error occurs stating 'Resize operations other than 4D and 5D are not supported' for a 3D operation

Issue Type

Others

onnx2tf version number

1.8.10

onnx version number

1.13.1

tensorflow version number

2.12.0rc1

Download URL for ONNX

make_sin_d.zip

Parameter Replacement JSON

{}

Description

  1. Purpose Product development

  2. What I encountered an issue when trying to convert an ONNX file using onnx2tf. The error message I received is as follows:

$ onnx2tf -i make_sin_d.onnx -kat f0
INFO: onnx_op_type: Resize onnx_op_name: /Resize_1
INFO:  input_name.1: /Where_3_output_0 shape: [1, 1, 42] dtype: float32
INFO:  input_name.2:  shape: None dtype: None
INFO:  input_name.3:  shape: None dtype: None
INFO:  input_name.4: /Concat_8_output_0 shape: [3] dtype: <class 'numpy.int64'>
INFO:  output_name.1: /Resize_1_output_0 shape: [1, 1, 5376] dtype: float32
ERROR: Currently, Resize operations other than 4D and 5D are not supported. Pull requests are welcome.
graph_node.name: /Resize_1 shape: (1, 1, 42)
ERROR: The trace log is below.
Traceback (most recent call last):
  File "/home/stealth/anaconda3/envs/mmvc15/lib/python3.9/site-packages/onnx2tf/utils/common_functions.py", line 280, in print_wrapper_func
    result = func(*args, **kwargs)
  File "/home/stealth/anaconda3/envs/mmvc15/lib/python3.9/site-packages/onnx2tf/utils/common_functions.py", line 358, in inverted_operation_enable_disable_wrapper_func
    result = func(*args, **kwargs)
  File "/home/stealth/anaconda3/envs/mmvc15/lib/python3.9/site-packages/onnx2tf/utils/common_functions.py", line 49, in get_replacement_parameter_wrapper_func
    func(*args, **kwargs)
  File "/home/stealth/anaconda3/envs/mmvc15/lib/python3.9/site-packages/onnx2tf/ops/Resize.py", line 243, in make_node
    sys.exit(1)
SystemExit: 1
ERROR: input_onnx_file_path: make_sin_d.onnx
ERROR: onnx_op_name: /Resize_1
  1. How I tried adding input parameter options to the test.
$ onnx2tf -i make_sin_d.onnx -ois f0:1,1,42 -cotof -cotoa 1e-1 -kat f0

I checked the vector size using Netron.

image

  1. Why I would like to make these modifications because I want to run the model in TFLite.

  2. Resources None

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 22 (11 by maintainers)

Most upvoted comments

Thank you so much!! I tried converting the ONNX generated without modifying the torch-side model and confirmed that the conversion worked without any issues.

I see. So, the method of forcibly breaking the shape into 4D and resizing it seems to make sense.

Yes, thanks to PINTO-san’s advice, I was able to gain a better understanding of the differences between ONNX and TensorFlow. I then tried addressing the issue by modifying the torch-side model to be in the shape of (B, 1, 1, W).

    def sinusoid(self, f0):
        """Calculate sine signals.

        Args:
            f0 (Tensor): F0 tensor (B, 1, T // hop_size).

        Returns:
            Tensor: Sines generated following NSF (B, 1, T).

        """
        f0 = f0.unsqueeze(-2)
        B, _, _, T= f0.size()
        vuv = interpolate((f0 > 0) * torch.ones_like(f0), scale_factor=(1, self.hop_size))
        radious = (interpolate(f0, scale_factor=(1, self.hop_size)) / self.sample_rate) % 1
        sine = vuv * torch.sin(torch.cumsum(radious, dim=3) * 2 * np.pi) * self.sine_amp
        if self.noise_amp > 0:
            noise_amp = vuv * self.noise_amp + (1.0 - vuv) * self.noise_amp / 3.0
            noise = torch.randn((B, 1, 1, T * self.hop_size), device=f0.device) * noise_amp
            sine = sine + noise
        sine = sine.squeeze(-2)

        return sine

With this change, I was able to confirm that the conversion using onnx2tf worked successfully.

image

It looks asymmetric x128, does this specification satisfy what you want to do?

https://www.tensorflow.org/api_docs/python/tf/keras/layers/UpSampling1D

image

I understand what you are saying, but unfortunately it is impossible.

https://www.tensorflow.org/api_docs/python/tf/image/resize

image

Pseudo-scaling should be reimplemented using TransposeConv or similar.