mean_iou¶
- paddle.fluid.layers.nn. mean_iou ( input, label, num_classes ) [source]
-
Mean Intersection-Over-Union is a common evaluation metric for semantic image segmentation, which first computes the IOU for each semantic class and then computes the average over classes. IOU is defined as follows:
\[\begin{split}IOU = \\frac{true\_positive}{(true\_positive + false\_positive + false\_negative)}.\end{split}\]The predictions are accumulated in a confusion matrix and mean-IOU is then calculated from it.
- Parameters
-
input (Tensor) – A n-D Tensor of prediction results for semantic labels with type int32 or int64.
label (Tensor) – A Tensor of ground truth labels with type int32 or int64. Its shape should be the same as input.
num_classes (int32) – The possible number of labels.
- Returns
-
Three Tensors.
-
- mean_iou(Tensor) A 1-D Tensor representing the mean intersection-over-union with shape [1].
-
Data type is float32.
-
- out_wrong(Tensor) A 1-D Tensor with shape [num_classes]. Data type is int32.
-
The wrong numbers of each class.
out_correct(Tensor): A 1-D Tensor with shape [num_classes]. Data type is int32. The correct numbers of each class.
-
Examples
import paddle iou_shape = [64, 32, 32] num_classes = 5 predict = paddle.randint(low=0, high=255, shape=iou_shape, dtype='int64') label = paddle.randint(low=0, high=255, shape=iou_shape, dtype='int64') mean_iou, out_wrong, out_correct = paddle.metric.mean_iou(predict, label, num_classes)