def encode_bboxes_tf(proposals, gt, config):
"""Encode bbox coordinates in a format
used for computing the loss"""
prop_x = proposals[..., 0]
prop_y = proposals[..., 1]
prop_w = proposals[..., 2]
prop_h = proposals[..., 3]
gt_x = gt[..., 0]
gt_y = gt[..., 1]
gt_w = gt[..., 2]
gt_h = gt[..., 3]
diff_x = (gt_x + 0.5*gt_w - prop_x - 0.5*prop_w)/prop_w
diff_y = (gt_y + 0.5*gt_h - prop_y - 0.5*prop_h)/prop_h
diff_w = tf.log(gt_w/prop_w)
diff_h = tf.log(gt_h/prop_h)
var_x, var_y, var_w, var_h = config['prior_variance']
x = tf.stack([diff_x/var_x, diff_y/var_y, diff_w/var_w, diff_h/var_h], -1)
return x
评论列表
文章目录