Repository: PaddlePaddle/PaddleDetection

Issue:
mask_rcnn_r50_fpn_1x_coco边训练边评估报错
我是在AiStudio上进行训练的
PaddleDetection 版本是release/2.3
PaddleSlim版本是2.2.2
指令如下：
python -m paddle.distributed.launch tools/train.py -c configs/mask_rcnn/mask_rcnn_r50_fpn_1x_coco.yml --slim_config configs/slim/quant/mask_rcnn_r50_fpn_1x_qat.yml --eval
错误如下：
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
[02/28 11:43:55] ppdet.engine INFO: Epoch: [0] [  0/227] learning_rate: 0.000001 loss_mask: 5.671147 loss_rpn_cls: 0.087396 loss_rpn_reg: 0.023211 loss_bbox_cls: 0.626898 loss_bbox_reg: 0.000150 loss: 6.408803 eta: 0:09:56 batch_cost: 0.5253 data_cost: 0.2701 ips: 1.9038 images/s
[02/28 11:43:59] ppdet.engine INFO: Epoch: [0] [ 20/227] learning_rate: 0.000201 loss_mask: 1.352157 loss_rpn_cls: 0.068374 loss_rpn_reg: 0.005640 loss_bbox_cls: 0.473194 loss_bbox_reg: 0.000134 loss: 1.902261 eta: 0:04:00 batch_cost: 0.2001 data_cost: 0.0003 ips: 4.9977 images/s
[02/28 11:44:03] ppdet.engine INFO: Epoch: [0] [ 40/227] learning_rate: 0.000401 loss_mask: 0.325770 loss_rpn_cls: 0.035264 loss_rpn_reg: 0.005288 loss_bbox_cls: 0.107983 loss_bbox_reg: 0.069622 loss: 0.613713 eta: 0:03:33 batch_cost: 0.1739 data_cost: 0.0003 ips: 5.7489 images/s
[02/28 11:44:07] ppdet.engine INFO: Epoch: [0] [ 60/227] learning_rate: 0.000600 loss_mask: 0.140169 loss_rpn_cls: 0.038117 loss_rpn_reg: 0.004111 loss_bbox_cls: 0.088131 loss_bbox_reg: 0.102879 loss: 0.365094 eta: 0:03:26 batch_cost: 0.1854 data_cost: 0.0003 ips: 5.3933 images/s
[02/28 11:44:10] ppdet.engine INFO: Epoch: [0] [ 80/227] learning_rate: 0.000800 loss_mask: 0.117784 loss_rpn_cls: 0.012792 loss_rpn_reg: 0.002675 loss_bbox_cls: 0.091548 loss_bbox_reg: 0.146030 loss: 0.361646 eta: 0:03:17 batch_cost: 0.1709 data_cost: 0.0003 ips: 5.8525 images/s
[02/28 11:44:14] ppdet.engine INFO: Epoch: [0] [100/227] learning_rate: 0.001000 loss_mask: 0.106181 loss_rpn_cls: 0.006102 loss_rpn_reg: 0.001934 loss_bbox_cls: 0.076618 loss_bbox_reg: 0.138277 loss: 0.357757 eta: 0:03:11 batch_cost: 0.1754 data_cost: 0.0003 ips: 5.7000 images/s
[02/28 11:44:17] ppdet.engine INFO: Epoch: [0] [120/227] learning_rate: 0.001000 loss_mask: 0.091514 loss_rpn_cls: 0.009782 loss_rpn_reg: 0.003362 loss_bbox_cls: 0.085947 loss_bbox_reg: 0.164348 loss: 0.385698 eta: 0:03:05 batch_cost: 0.1717 data_cost: 0.0003 ips: 5.8238 images/s
[02/28 11:44:20] ppdet.engine INFO: Epoch: [0] [140/227] learning_rate: 0.001000 loss_mask: 0.073411 loss_rpn_cls: 0.002619 loss_rpn_reg: 0.002871 loss_bbox_cls: 0.085698 loss_bbox_reg: 0.180846 loss: 0.339970 eta: 0:02:59 batch_cost: 0.1710 data_cost: 0.0003 ips: 5.8483 images/s
[02/28 11:44:24] ppdet.engine INFO: Epoch: [0] [160/227] learning_rate: 0.001000 loss_mask: 0.080978 loss_rpn_cls: 0.001982 loss_rpn_reg: 0.002556 loss_bbox_cls: 0.071626 loss_bbox_reg: 0.177487 loss: 0.321085 eta: 0:02:56 batch_cost: 0.1841 data_cost: 0.0003 ips: 5.4330 images/s
[02/28 11:44:28] ppdet.engine INFO: Epoch: [0] [180/227] learning_rate: 0.001000 loss_mask: 0.087237 loss_rpn_cls: 0.002387 loss_rpn_reg: 0.002047 loss_bbox_cls: 0.055845 loss_bbox_reg: 0.132736 loss: 0.285331 eta: 0:02:51 batch_cost: 0.1685 data_cost: 0.0003 ips: 5.9364 images/s
[02/28 11:44:31] ppdet.engine INFO: Epoch: [0] [200/227] learning_rate: 0.001000 loss_mask: 0.067679 loss_rpn_cls: 0.000783 loss_rpn_reg: 0.002064 loss_bbox_cls: 0.041431 loss_bbox_reg: 0.082881 loss: 0.199531 eta: 0:02:47 batch_cost: 0.1708 data_cost: 0.0003 ips: 5.8540 images/s
[02/28 11:44:35] ppdet.engine INFO: Epoch: [0] [220/227] learning_rate: 0.001000 loss_mask: 0.085638 loss_rpn_cls: 0.000932 loss_rpn_reg: 0.002670 loss_bbox_cls: 0.037691 loss_bbox_reg: 0.065090 loss: 0.203334 eta: 0:02:43 batch_cost: 0.1745 data_cost: 0.0003 ips: 5.7303 images/s
[02/28 11:44:37] ppdet.utils.checkpoint INFO: Save checkpoint: output/mask_rcnn_r50_fpn_1x_qat
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
Traceback (most recent call last):
  File "tools/train.py", line 177, in <module>
    main()
  File "tools/train.py", line 173, in main
    run(FLAGS, cfg)
  File "tools/train.py", line 127, in run
    trainer.train(FLAGS.eval)
  File "/home/aistudio/work/PaddleDetection/ppdet/engine/trainer.py", line 453, in train
    self._eval_with_loader(self._eval_loader)
  File "/home/aistudio/work/PaddleDetection/ppdet/engine/trainer.py", line 475, in _eval_with_loader
    outs = self.model(data)
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py", line 917, in __call__
    return self._dygraph_call_func(*inputs, **kwargs)
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py", line 907, in _dygraph_call_func
    outputs = self.forward(*inputs, **kwargs)
  File "/home/aistudio/work/PaddleDetection/ppdet/modeling/architectures/meta_arch.py", line 56, in forward
    out = self.get_pred()
  File "/home/aistudio/work/PaddleDetection/ppdet/modeling/architectures/mask_rcnn.py", line 133, in get_pred
    bbox_pred, bbox_num, mask_pred = self._forward()
  File "/home/aistudio/work/PaddleDetection/ppdet/modeling/architectures/mask_rcnn.py", line 115, in _forward
    bbox_pred = self.bbox_post_process.get_pred(bbox, bbox_num,
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py", line 1110, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'MAOutputScaleLayer' object has no attribute 'get_pred'
INFO 2022-02-28 11:44:45,339 launch_utils.py:341] terminate all the procs
ERROR 2022-02-28 11:44:45,339 launch_utils.py:604] ABORT!!! Out of all 1 trainers, the trainer process with rank=[0] was aborted. Please check its log.
INFO 2022-02-28 11:44:49,344 launch_utils.py:341] terminate all the procs
INFO 2022-02-28 11:44:49,344 launch.py:311] Local processes completed.


Discussion:
@xing5933 感谢反馈，PaddlePaddle版本是多少？我们定位解决下问题。
paddlepaddle-gpu:2.2.2.post101
@yghstill 大佬，有消息了吗

Resolving patch:
diff --git a/ppdet/modeling/post_process.py b/ppdet/modeling/post_process.py
--- a/ppdet/modeling/post_process.py
+++ b/ppdet/modeling/post_process.py
@@ -33,7 +33,7 @@
 
 
 @register
-class BBoxPostProcess(nn.Layer):
+class BBoxPostProcess(object):
     __shared__ = ['num_classes', 'export_onnx']
     __inject__ = ['decode', 'nms']
 
@@ -45,9 +45,9 @@ def __init__(self, num_classes=80, decode=None, nms=None,
         self.nms = nms
         self.export_onnx = export_onnx
 
-    def forward(self, head_out, rois, im_shape, scale_factor):
+    def __call__(self, head_out, rois, im_shape, scale_factor):
         """
-        Decode the bbox and do NMS if needed. 
+        Decode the bbox and do NMS if needed.
 
         Args:
             head_out (tuple): bbox_pred and cls_prob of bbox_head output.
@@ -85,7 +85,7 @@ def get_pred(self, bboxes, bbox_num, im_shape, scale_factor):
         """
         Rescale, clip and filter the bbox from the output of NMS to 
         get final prediction. 
-        
+
         Notes:
         Currently only support bs = 1.
 


Test patch: