Skip to content

Commit

Permalink
polish and fix some code (PaddlePaddle#4643)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxinxin08 authored Nov 22, 2021
1 parent bfc5bf1 commit e07f9b9
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
1 change: 0 additions & 1 deletion configs/dota/s2anet_1x_spine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions configs/dota/s2anet_conv_2x_dota.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions ppdet/ext_op/rbox_iou_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ std::vector<paddle::Tensor> 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(),
Expand Down
3 changes: 1 addition & 2 deletions ppdet/ext_op/rbox_iou_op.cu
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ std::vector<paddle::Tensor> 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);
Expand Down
8 changes: 4 additions & 4 deletions ppdet/modeling/bbox_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e07f9b9

Please sign in to comment.