Repository: PaddlePaddle/PaddleSeg

Issue:
RTformer在测试阶段报错
![image](https://user-images.githubusercontent.com/83204995/196131861-42e7695b-2c7c-418d-bb01-b1cf1fc67a8c.png)
![image](https://user-images.githubusercontent.com/83204995/196132012-25cfef5f-a933-46ba-b27a-90b4c96ca5e6.png)
可以训练，在测试阶段报错，如上



Discussion:
您好，请给出具体的使用环境及数据集，方便复现及排查问题
大概率是环境问题，可以试着参考seg文档，排查并验证一下环境
上面的图1就是运行具体环境：

------------Environment Information-------------
platform: Linux-5.4.0-59-generic-x86_64-with-debian-buster-sid
Python: 3.6.13 |Anaconda, Inc.| (default, Jun  4 2021, 14:25:59) [GCC 7.5.0]
Paddle compiled with cuda: True
NVCC: Cuda compilation tools, release 10.2, V10.2.89
cudnn: 8.0
GPUs used: 1
CUDA_VISIBLE_DEVICES: None
GPU: ['GPU 0: NVIDIA GeForce']
GCC: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
PaddleSeg: develop
PaddlePaddle: 2.2.2
OpenCV: 4.5.5
------------------------------------------------
2022-10-17 16:46:38 [INFO]	
---------------Config Information---------------
batch_size: 6
export:
  transforms:
  - keep_ratio: true
    target_size:
    - 2048
    - 512
    type: Resize
  - mean:
    - 0.485
    - 0.456
    - 0.406
    std:
    - 0.229
    - 0.224
    - 0.225
    type: Normalize
iters: 240000
loss:
  coef:
  - 1
  - 0.4
  types:
  - ignore_index: 255
    type: CrossEntropyLoss
lr_scheduler:
  end_lr: 1.0e-06
  learning_rate: 0.0001
  power: 1.0
  type: PolynomialDecay
  warmup_iters: 1500
  warmup_start_lr: 1.0e-06
model:
  base_channels: 32
  head_channels: 64
  in_channels: 3
  num_classes: 19
  pretrained: https://paddleseg.bj.bcebos.com/dygraph/backbone/rtformer_slim_backbone_imagenet_pretrained.zip
  type: RTFormer
  use_injection:
  - true
  - true
optimizer:
  beta1: 0.9
  beta2: 0.999
  type: AdamW
  weight_decay: 0.0125
train_dataset:
  dataset_root: data/cityscapes
  mode: train
  transforms:
  - max_scale_factor: 2.0
    min_scale_factor: 0.5
    scale_step_size: 0.25
    type: ResizeStepScaling
  - crop_size:
    - 1024
    - 512
    type: RandomPaddingCrop
  - type: RandomHorizontalFlip
  - brightness_range: 0.4
    contrast_range: 0.4
    saturation_range: 0.4
    type: RandomDistort
  - mean:
    - 0.485
    - 0.456
    - 0.406
    std:
    - 0.229
    - 0.224
    - 0.225
    type: Normalize
  type: Cityscapes
val_dataset:
  dataset_root: data/cityscapes
  mode: val
  transforms:
  - keep_ratio: true
    target_size:
    - 2048
    - 1024
    type: Resize
  - mean:
    - 0.485
    - 0.456
    - 0.406
    std:
    - 0.229
    - 0.224
    - 0.225
    type: Normalize
  type: Cityscapes
------------------------------------------------

环境没有问题，pp_lite可以正常运行。
![image](https://user-images.githubusercontent.com/83204995/196150907-c97aa8bc-adaa-4357-965a-e493b448505e.png)
数据集是下载的pp_lite文档中给出的cityscapes数据集。
报错出现在训练中的评估部分，就是其实是可以正常训练的，但是一跑到验证的评估部分就会报错，
我在另外的平台上也复现出了相同的报错，应该是个BUG。
en, 使用paddle2.2版本复现了该问题。 建议你先升级一下paddle 2.3，验证是ok。我们会尽快修复该问题。

Resolving patch:
diff --git a/paddleseg/core/infer.py b/paddleseg/core/infer.py
--- a/paddleseg/core/infer.py
+++ b/paddleseg/core/infer.py
@@ -34,10 +34,10 @@ def reverse_transform(pred, trans_info, mode='nearest'):
             h, w = item[1][0], item[1][1]
             if paddle.get_device() == 'cpu' and dtype in intTypeList:
                 pred = paddle.cast(pred, 'float32')
-                pred = F.interpolate(pred, (h, w), mode=mode)
+                pred = F.interpolate(pred, [h, w], mode=mode)
                 pred = paddle.cast(pred, dtype)
             else:
-                pred = F.interpolate(pred, (h, w), mode=mode)
+                pred = F.interpolate(pred, [h, w], mode=mode)
         elif trans_mode == 'padding':
             h, w = item[1][0], item[1][1]
             pred = pred[:, :, 0:h, 0:w]
@@ -211,7 +211,7 @@ def aug_inference(model,
     for scale in scales:
         h = int(h_input * scale + 0.5)
         w = int(w_input * scale + 0.5)
-        im = F.interpolate(im, (h, w), mode='bilinear')
+        im = F.interpolate(im, [h, w], mode='bilinear')
         for flip in flip_comb:
             im_flip = tensor_flip(im, flip)
             logit = inference(
@@ -221,7 +221,7 @@ def aug_inference(model,
                 crop_size=crop_size,
                 stride=stride)
             logit = tensor_flip(logit, flip)
-            logit = F.interpolate(logit, (h_input, w_input), mode='bilinear')
+            logit = F.interpolate(logit, [h_input, w_input], mode='bilinear')
 
             logit = F.softmax(logit, axis=1)
             final_logit = final_logit + logit
diff --git a/paddleseg/models/losses/rmi_loss.py b/paddleseg/models/losses/rmi_loss.py
--- a/paddleseg/models/losses/rmi_loss.py
+++ b/paddleseg/models/losses/rmi_loss.py
@@ -155,10 +155,10 @@ def rmi_lower_bound(self, labels_4D, probs_4D):
                 shape = labels_4D.shape
                 new_h, new_w = shape[2] // s, shape[3] // s
                 labels_4D = F.interpolate(
-                    labels_4D, size=(new_h, new_w), mode='nearest')
+                    labels_4D, size=[new_h, new_w], mode='nearest')
                 probs_4D = F.interpolate(
                     probs_4D,
-                    size=(new_h, new_w),
+                    size=[new_h, new_w],
                     mode='bilinear',
                     align_corners=True)
             else:


Test patch: