-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Different behavior of bilinear interpolation between resize_images and ONNX Upsample #147
Comments
Thank you for detail report. I saw your commits master...syoyo:resize_images roughly and looks fine.
Please void output value check between Chainer and ONNXRuntime, like this def test_output(self):
self.check_out_values = None # skip output value check
self.expect(self.model, self.x) Test tool does not have "skip all output value check" option, so by adding |
Doing away with the PixelShuffle (depth2space) upsampling layer that was quite prone to checkerboard artifacts. Replacing it with NearestNeighbour interpolation instead. Note that previously the Convolutional2D layer was before (pre) the Upsampling, and now it is placed after (post), and we've reduced the channels from 256 to 64, This chainer implementation of ours now follows the ESRGAN pytorch implementation as in https://github.com/xinntao/BasicSR/blob/85d7b14107a2705683b2568f77fe1c684e29f530/codes/models/modules/RRDBNet_arch.py very closely! Experiment training details logged at https://www.comet.ml/weiji14/deepbedmap/a3b87a2f383243c7a66d18d146aafe61 with an RMSE_test of 73.24, not great but qualitatively there's less of a checkerboard artifact. Note that onnx-chainer 1.4.1 raises a warning when exporting the resize_images function that we are suppressing. Full UserWarning is as follows:" `resize_images` is mapped to `Upsampling` ONNX op with bilinear interpolation. Behavior of bilinear interpolation differs from each implementation. See the issue chainer/onnx-chainer#147 for details".
I have implemented exporting
resize_images
to ONNX by lowering it intoUpsample
ONNX op as did inunpooling_2D
.https://github.com/syoyo/onnx-chainer/tree/resize_images
and wanted to submit PR, but found a unit test fails due to different behavior of bilinear interpolation in Chainer and onnxruntime(and also TensorFlow/OpenCV which is a reference).
I use
resize_images
for pyramid pooling, thus need to embed resizing op into a model file.So, I've tracked down this problem and here is a summary:
Input and output
Input shape: (2x2). [[64, 32], [64, 32]]
Output shape: (4x4) (Scaling factor is 2x)
Result: [64, ***, ***, 32] (Just check the first row)
Chainer(v5.4)
it results in [64, 53.333336, 42.666668, 32].
(can be reproducable by running
tests/functions_tests/test_arrays.py
)onnxruntime(v0.3.0)
it results in [64, 48, 32, 32].
(can be reproducable by running
tests/functions_tests/test_arrays.py
)TensorFlow
cv2.resize(should be the ground truth)
Current Chainer's behavior is same with the result of TF
r1.13.1
but there was a bugtensorflow/tensorflow#6720
and recently there had a fix to TF's
resize_images
with this commit: tensorflow/tensorflow@371c96dWhat I should do?
Correct behavior will be the one in
cv2.resize
and tf r2.0([64, 56, 40, 32]), so we are better to move towards this direction in the last(i.e. add a fix or implement newresize_images
into Chainer), but for a while there will be some options:resize_images
and send PRResize
op. sinceUpsample
will be deprecated in opset 10)References
The text was updated successfully, but these errors were encountered: