소스 검색

resize_bilinear of HRnet changed for onnx opset10

Channingss 5 년 전
부모
커밋
a20bc127fd
2개의 변경된 파일12개의 추가작업 그리고 5개의 파일을 삭제
  1. 4 1
      paddlex/cv/nets/hrnet.py
  2. 8 4
      paddlex/cv/nets/segmentation/hrnet.py

+ 4 - 1
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))

+ 8 - 4
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)