From e07f9b9cceaae9f554b9e522d6213fd56776c823 Mon Sep 17 00:00:00 2001 From: wangxinxin08 <69842442+wangxinxin08@users.noreply.github.com> Date: Mon, 22 Nov 2021 13:39:52 +0800 Subject: [PATCH] polish and fix some code (#4643) --- configs/dota/s2anet_1x_spine.yml | 1 - configs/dota/s2anet_conv_2x_dota.yml | 1 + ppdet/ext_op/rbox_iou_op.cc | 3 +-- ppdet/ext_op/rbox_iou_op.cu | 3 +-- ppdet/modeling/bbox_utils.py | 8 ++++---- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/configs/dota/s2anet_1x_spine.yml b/configs/dota/s2anet_1x_spine.yml index 6ebe668c8..5cf215b54 100644 --- a/configs/dota/s2anet_1x_spine.yml +++ b/configs/dota/s2anet_1x_spine.yml @@ -27,4 +27,3 @@ S2ANetHead: reg_loss_weight: [1.0, 1.0, 1.0, 1.0, 1.05] cls_loss_weight: [1.05, 1.0] reg_loss_type: 'l1' - is_training: True diff --git a/configs/dota/s2anet_conv_2x_dota.yml b/configs/dota/s2anet_conv_2x_dota.yml index eaca36207..795ba242b 100644 --- a/configs/dota/s2anet_conv_2x_dota.yml +++ b/configs/dota/s2anet_conv_2x_dota.yml @@ -6,6 +6,7 @@ _BASE_: [ '_base_/s2anet_reader.yml', ] weights: output/s2anet_conv_1x_dota/model_final +pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/ResNet50_cos_pretrained.pdparams ResNet: depth: 50 diff --git a/ppdet/ext_op/rbox_iou_op.cc b/ppdet/ext_op/rbox_iou_op.cc index ce27e8e91..6031953d2 100644 --- a/ppdet/ext_op/rbox_iou_op.cc +++ b/ppdet/ext_op/rbox_iou_op.cc @@ -45,8 +45,7 @@ std::vector RboxIouCPUForward(const paddle::Tensor& rbox1, const auto rbox1_num = rbox1.shape()[0]; auto rbox2_num = rbox2.shape()[0]; - auto output = paddle::Tensor(paddle::PlaceType::kCPU); - output.reshape({rbox1_num, rbox2_num}); + auto output = paddle::Tensor(paddle::PlaceType::kCPU, {rbox1_num, rbox2_num}); PD_DISPATCH_FLOATING_TYPES( rbox1.type(), diff --git a/ppdet/ext_op/rbox_iou_op.cu b/ppdet/ext_op/rbox_iou_op.cu index 72cac2389..8ec43e54b 100644 --- a/ppdet/ext_op/rbox_iou_op.cu +++ b/ppdet/ext_op/rbox_iou_op.cu @@ -94,8 +94,7 @@ std::vector RboxIouCUDAForward(const paddle::Tensor& rbox1, cons auto rbox1_num = rbox1.shape()[0]; auto rbox2_num = rbox2.shape()[0]; - auto output = paddle::Tensor(paddle::PlaceType::kGPU); - output.reshape({rbox1_num, rbox2_num}); + auto output = paddle::Tensor(paddle::PlaceType::kGPU, {rbox1_num, rbox2_num}); const int blocks_x = CeilDiv(rbox1_num, BLOCK_DIM_X); const int blocks_y = CeilDiv(rbox2_num, BLOCK_DIM_Y); diff --git a/ppdet/modeling/bbox_utils.py b/ppdet/modeling/bbox_utils.py index 789d06467..e040ba69b 100644 --- a/ppdet/modeling/bbox_utils.py +++ b/ppdet/modeling/bbox_utils.py @@ -529,18 +529,18 @@ def poly2rbox(polys): rbox_angle = 0 if edge1 > edge2: rbox_angle = np.arctan2( - np.float(pt2[1] - pt1[1]), np.float(pt2[0] - pt1[0])) + float(pt2[1] - pt1[1]), float(pt2[0] - pt1[0])) elif edge2 >= edge1: rbox_angle = np.arctan2( - np.float(pt4[1] - pt1[1]), np.float(pt4[0] - pt1[0])) + float(pt4[1] - pt1[1]), float(pt4[0] - pt1[0])) def norm_angle(angle, range=[-np.pi / 4, np.pi]): return (angle - range[0]) % range[1] + range[0] rbox_angle = norm_angle(rbox_angle) - x_ctr = np.float(pt1[0] + pt3[0]) / 2 - y_ctr = np.float(pt1[1] + pt3[1]) / 2 + x_ctr = float(pt1[0] + pt3[0]) / 2 + y_ctr = float(pt1[1] + pt3[1]) / 2 rotated_box = np.array([x_ctr, y_ctr, width, height, rbox_angle]) rotated_boxes.append(rotated_box) ret_rotated_boxes = np.array(rotated_boxes) -- GitLab