xingyizhou / CenterNet2

Two-stage CenterNet
Apache License 2.0
1.2k stars 188 forks source link

AttributeError: 'CustomFastRCNNOutputs' object has no attribute '_predict_boxes' #69

Open secortot opened 2 years ago

secortot commented 2 years ago

Instructions To Reproduce the 🐛 Bug:

  1. Full runnable code or full changes you made:
    when i use CenterNet2_R2-101-DCN-BiFPN_4x+4x_1560_ST moudel, and make ROI_BOX_HEAD:BBOX_REG_LOSS_TYPE: "giou", it turns the below error:
    AttributeError: 'CustomFastRCNNOutputs' object has no attribute '_predict_boxes'
  2. What exact command you run: ${PYTHON} projects/CenterNet2/train_net.py --num-gpus 1 --config-file projects/CenterNet2/configs/CenterNet2_R2-101-DCN-BiFPN_4x+4x_1560_ST.yaml
  3. Full logs or other relevant observations:
    
    Traceback (most recent call last):
    File "projects/CenterNet2/train_net.py", line 232, in <module>
    args=(args,),
    File "/root/paddlejob/workspace/env_run/detectron2/engine/launch.py", line 62, in launch
    main_func(*args)
    File "projects/CenterNet2/train_net.py", line 213, in main
    do_train(cfg, model, resume=args.resume)
    File "projects/CenterNet2/train_net.py", line 125, in do_train
    loss_dict = model(data)
    File "/root/paddlejob/workspace/env_run/py36_detectron0.4/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
    File "/root/paddlejob/workspace/env_run/detectron2/modeling/meta_arch/rcnn.py", line 166, in forward
    _, detector_losses = self.roi_heads(images, features, proposals, gt_instances)
    File "/root/paddlejob/workspace/env_run/py36_detectron0.4/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
    File "/root/paddlejob/workspace/env_run/projects/CenterNet2/centernet/modeling/roi_heads/custom_roi_heads.py", line 166, in forward
    losses = self._forward_box(features, proposals, targets)
    File "/root/paddlejob/workspace/env_run/projects/CenterNet2/centernet/modeling/roi_heads/custom_roi_heads.py", line 128, in _forward_box
    stage_losses = predictor.losses(predictions, proposals)
    File "/root/paddlejob/workspace/env_run/projects/CenterNet2/centernet/modeling/roi_heads/custom_fast_rcnn.py", line 223, in losses
    self.freq_weight if use_advanced_loss else None, 
    File "/root/paddlejob/workspace/env_run/projects/CenterNet2/centernet/modeling/roi_heads/custom_fast_rcnn.py", line 159, in losses
    "loss_box_reg": self.box_reg_loss()
    File "/root/paddlejob/workspace/env_run/projects/CenterNet2/centernet/modeling/roi_heads/custom_fast_rcnn.py", line 142, in box_reg_loss
    self._predict_boxes()[fg_inds[:, None], gt_class_cols],
    AttributeError: 'CustomFastRCNNOutputs' object has no attribute '_predict_boxes'
secortot commented 2 years ago

add code below in CenterNet2/centernet/modeling/roi_heads/custom_fast_rcnn.py could slove: def _predict_boxes(self): """ Returns: Tensor: A Tensors of predicted class-specific or class-agnostic boxes for all images in a batch. Element i has shape (Ri, K * B) or (Ri, B), where Ri is the number of predicted objects for image i and B is the box dimension (4 or 5) """ return self.box2box_transform.apply_deltas(self.pred_proposal_deltas, self.proposals.tensor)