gmalivenko / onnx2keras

Convert ONNX model graph to Keras model format.
MIT License
195 stars 116 forks source link

Does it currently support upsample_bilinear? #27

Open Brave731 opened 4 years ago

Brave731 commented 4 years ago

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

gmalivenko commented 4 years ago

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.

Brave731 commented 4 years ago

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

xiaozhi2015 commented 4 years ago

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

Brave731 commented 4 years ago

@xiaozhi2015 转换后结果不一致

gmalivenko commented 4 years ago

@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.