onnx2keras icon indicating copy to clipboard operation
onnx2keras copied to clipboard

Does it currently support upsample_bilinear?

Open Brave731 opened this issue 5 years ago • 5 comments

Code: z = F.upsample(y, size=y.size()[2:], mode='bilinear')

Traceback (most recent call last): File ".\test.py", line 43, in k_model = converter.pytorch_to_keras(model, input_var, [(3, 224, 224)], verbose=True) File "D:\Python36\lib\site-packages\pytorch2keras\converter.py", line 73, in pytorch_to_keras verbose=verbose, change_ordering=change_ordering) File "D:\Python36\lib\site-packages\onnx2keras\converter.py", line 174, in onnx_to_keras keras_names File "D:\Python36\lib\site-packages\onnx2keras\operation_layers.py", line 234, in convert_cast if is_numpy(layers[node.input[0]]) and is_numpy(layers[node.input[1]]): IndexError: list index (1) out of range

Brave731 avatar Nov 15 '19 06:11 Brave731

Hello @Brave731. Unfortunately, the converter doesn't support upsample_bilinear for now due to very different results for the same parameters using PyTorch and Tensorflow. But you can replace your Bilinear upsample with ConvTranspose2d for example.

gmalivenko avatar Nov 18 '19 07:11 gmalivenko

@nerox8664 Thanks for your reply, the model can be converted。

Brave731 avatar Nov 19 '19 08:11 Brave731

How did you convert it successfully? By replacing upsample_bilinear with ConvTranspose2d? @Brave731

xiaozhi2015 avatar Jun 30 '20 09:06 xiaozhi2015

@xiaozhi2015 转换后结果不一致

Brave731 avatar Jun 30 '20 09:06 Brave731

@xiaozhi2015 @Brave731 you may need to fine-tune you model (or at least to train inserted ConvTranspose2d layer) after replacing upsampling method. For some models you will get very similar results, but it depends on your ConvTranspose2d parameters and network architecture.

gmalivenko avatar Jun 30 '20 10:06 gmalivenko