def test_batch_iou(self):
with self.test_session() as sess:
anchors = set_anchors(img_shape=[config.IMG_HEIGHT, config.IMG_WIDTH],
fea_shape=[config.FEA_HEIGHT, config.FEA_WIDTH])
anchors_shape = anchors.get_shape().as_list()
fea_h = anchors_shape[0]
fea_w = anchors_shape[1]
num_anchors = anchors_shape[2] * fea_h * fea_w
anchors = tf.reshape(anchors, [num_anchors, 4]) # reshape anchors
anchors = xywh_to_yxyx(anchors)
bbox = tf.constant([0.75, 0.75, 0.2, 0.2], dtype=tf.float32)
bbox = xywh_to_yxyx(bbox)
iou = batch_iou(anchors, bbox)
anchor_idx = tf.arg_max(iou, dimension=0)
anchors, output, anchor_idx = sess.run([anchors, iou, anchor_idx])
print(anchors)
print(output)
print(anchor_idx)
评论列表
文章目录