From a20bc127fdc90537e02e971e52632f27599b7b90 Mon Sep 17 00:00:00 2001 From: Channingss Date: Tue, 7 Jul 2020 11:42:49 +0000 Subject: [PATCH] resize_bilinear of HRnet changed for onnx opset10 --- paddlex/cv/nets/hrnet.py | 5 ++++- paddlex/cv/nets/segmentation/hrnet.py | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/paddlex/cv/nets/hrnet.py b/paddlex/cv/nets/hrnet.py index 561c759..c366f13 100644 --- a/paddlex/cv/nets/hrnet.py +++ b/paddlex/cv/nets/hrnet.py @@ -235,7 +235,10 @@ class HRNet(object): name=name + '_layer_' + str(i + 1) + '_' + str(j + 1)) if self.feature_maps == "stage4": y = fluid.layers.resize_bilinear( - input=y, out_shape=[height, width]) + input=y, + out_shape=[height, width], + align_corners=False, + align_mode=1) else: y = fluid.layers.resize_nearest( input=y, scale=2**(j - i)) diff --git a/paddlex/cv/nets/segmentation/hrnet.py b/paddlex/cv/nets/segmentation/hrnet.py index 209da9b..5193b3f 100644 --- a/paddlex/cv/nets/segmentation/hrnet.py +++ b/paddlex/cv/nets/segmentation/hrnet.py @@ -77,9 +77,12 @@ class HRNet(object): st4 = self.backbone(image) # upsample shape = fluid.layers.shape(st4[0])[-2:] - st4[1] = fluid.layers.resize_bilinear(st4[1], out_shape=shape) - st4[2] = fluid.layers.resize_bilinear(st4[2], out_shape=shape) - st4[3] = fluid.layers.resize_bilinear(st4[3], out_shape=shape) + st4[1] = fluid.layers.resize_bilinear( + st4[1], out_shape=shape, align_corners=False, align_mode=1) + st4[2] = fluid.layers.resize_bilinear( + st4[2], out_shape=shape, align_corners=False, align_mode=1) + st4[3] = fluid.layers.resize_bilinear( + st4[3], out_shape=shape, align_corners=False, align_mode=1) out = fluid.layers.concat(st4, axis=1) last_channels = sum(self.backbone.channels[str(self.backbone.width)][ @@ -104,7 +107,8 @@ class HRNet(object): bias_attr=False) input_shape = fluid.layers.shape(image)[-2:] - logit = fluid.layers.resize_bilinear(out, input_shape) + logit = fluid.layers.resize_bilinear( + out, input_shape, align_corners=False, align_mode=1) if self.num_classes == 1: out = sigmoid_to_softmax(logit) -- GitLab