Reputation: 777
I am using tensorflow 0.11 and am running some image segmentation tests. In image segmentation, we usually compute the IoU. How can I make use of tensorflow's tf.contrib.metrics.streaming_mean_iou?
mIoU, confusionMatrix = tf.contrib.metrics.streaming_mean_iou(pred_labels_vec,gt_labels_vec,NUM_CLASS)
init = tf.initialize_local_variables()
sess.run(init)
for i in range(1000):
iou, _ = sess.run([mIoU, confusionMatrix])
print(iou)
Upvotes: 1
Views: 1543
Reputation: 2356
Your code is correct to compute the mean iou.
If you want to compute the IoU for each class, see this question. You can compute them via the confusion matrix. When you run streaming_mean_iou
, tensorflow has already created a local variable, called total_confusion_matrix (same for tf 0.11). Then you can get this matrix by calling tf.local_variables()
, or through get_tensor_by_name
.
Upvotes: 2