Upsampling with bicubic in ONNXNetwork

3 views (last 30 days)
I have trained a network with PyTorch with UNet architecture and converted it into ONNX format by torch.onnx.export. Specifically I used 'bicubic' as the mode for nn.Upsample, but when I tried importing the ONNX network to MATLAB I got the error: The value 'cubic' is not supported for the attribute 'mode'. Upon reading about the resize2dLayer, I see that it only supports 'bilinear'. Is there any way to work around so I could use my trained network without modifying the architecture?
Thanks.

Answers (1)

Sivylla Paraskevopoulou
Sivylla Paraskevopoulou on 29 Sep 2022
Which MATLAB version are you using? Since R2021b, the importONNXNetwork and importONNXLayers functions automatically generate custom layers for ONNX operators that they can't convert to built-in MATLAB layers (in many cases). So that might help you with importing. You can also use importONNXLayers, and import the layer as a placeholder layer, which you have to find and replace with a custom layer to keep the settings you want.
And finally, you can get a pretrained U-Net MATLAB network without having to import. Go to MATLAB Deep Learning Model Hub.

Categories

Find more on Image Data Workflows in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!