Closed byfate closed 3 years ago
what i did as follows: What I did as follows: 1 first I change the head parameters: '''python heads = {'hm': num_classes[args.dataset], 'wh': 2, 'reg': 2, 'ang': 1 } ''' 2 then I change the gt generation code as follows '''python wh[k, 0:2] = 1. bbox_w, 1. bbox_h reg[k] = ct - ct_int # 记录回归的center offset_x offset_y reg_mask[k] = 1 # 类别mask 置为1 assert 0 >= theta >= -90, "error angle" ang[k] = 1.*theta # 角度 ''' 3 I change the decode code ''' detections = torch.cat([xs, # cen_x ys, # cen_y wh, ang, scores, clses], dim=2) ''' 4 I change the decode prediction code '''python x = int(pred[0]) # center_y y = int(pred[1]) # center_y
height = int(pred[2]) # w width = int(pred[3]) # h
angle = pred[4] # 注意预测出来的是角度 angle = angle if angle<=0 else angle-180 anglePi = angle/180.*np.pi
cosA = np.cos(anglePi) sinA = np.sin(anglePi)
x1 = x - 0.5 width y1 = y - 0.5 height
x0 = x + 0.5 * width y0 = y1
x2 = x1 y2 = y + 0.5 * height
x3 = x0 y3 = y2
x0n = (x0 - x) cosA - (y0 - y) sinA + x y0n = (x0 - x) sinA + (y0 - y) cosA + y
x1n = (x1 - x) cosA - (y1 - y) sinA + x y1n = (x1 - x) sinA + (y1 - y) cosA + y
x2n = (x2 - x) cosA - (y2 - y) sinA + x y2n = (x2 - x) sinA + (y2 - y) cosA + y
x3n = (x3 - x) cosA - (y3 - y) sinA + x y3n = (x3 - x) sinA + (y3 - y) cosA + y tl = np.asarray([x0n, y0n], np.float32) tr = np.asarray([x1n, y1n], np.float32) br =np.asarray([x2n, y2n], np.float32) bl = np.asarray([x3n, y3n], np.float32) score = pred[5] # 分数 clse = pred[6] # 类别 pts = np.asarray([tl, tr, br, bl], np.float32) # num42 top right; bottom right; bottom left;bottom left pts[:, 0] = pts[:, 0] down_ratio / args.input_w w pts[:, 1] = pts[:, 1] down_ratio / args.input_w w ''' Hope you can help.3q you
I used a weighted loss as loss = hm_loss+wh_loss+off_loss+0.1*angle_loss
, if your groud_truth angle has no problem it should be good. You can draw the output using OpenCV
functions (pts = cv2.boxPoints(((cen_x, cen_y), (bbox_w, bbox_h), theta)))
instead of doing affine by yourself.
I used a weighted loss as
loss = hm_loss+wh_loss+off_loss+0.1*angle_loss
, if your groud_truth angle has no problem it should be good. You can draw the output usingOpenCV
functions(pts = cv2.boxPoints(((cen_x, cen_y), (bbox_w, bbox_h), theta)))
instead of doing affine by yourself.
OK I will try it, thank for you replying.by the way,in you baseline method ,when you generate your gt ,have you change you angel parameter to radian measure in you code ,I see in the paper ,it is range from [-90,0]. appreciated.
I used a weighted loss as
loss = hm_loss+wh_loss+off_loss+0.1*angle_loss
, if your groud_truth angle has no problem it should be good. You can draw the output usingOpenCV
functions(pts = cv2.boxPoints(((cen_x, cen_y), (bbox_w, bbox_h), theta)))
instead of doing affine by yourself.OK I will try it, thank for you replying.by the way,in you baseline method ,when you generate your gt ,have you change you angel parameter to radian measure in you code ,I see in the paper ,it is range from [-90,0]. appreciated.
Angle ranges from [-90, 0)
OK,got it.thank you
I try to reproduce the baseline method,but i failed. I change the head and docode_prediction code,but the network can not converge, could you realease you baseline method as a branch ,appreciated.