def run(proposals, gt, device='/cpu:0'):
with tf.device(device):
proposals = tf.expand_dims(proposals, axis=1)
proposals = tf.tile(proposals, [1, M, 1])
gt = tf.expand_dims(gt, axis=0)
gt = tf.tile(gt, [N, 1, 1])
proposals = tf.reshape(proposals, (N*M, d))
gt = tf.reshape(gt, (N*M, d))
# shape is N*M x 1
iou_metric = tf.map_fn(model.iou, tf.stack([proposals, gt], axis=1))
iou_metric = tf.reshape(iou_metric, [N, M])
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
sess.run(iou_metric)
# result is 2min48s
评论列表
文章目录