Skip to contents

Per-pixel argmax over model(image) -> (H,W,K) scores; when y_true is given, per-class IoU = |P_k & G_k| / |P_k | G_k|, mean over classes present, pixel accuracy, confusion matrix.

Usage

morie_geron_semantic_segmentation(image, model, y_true = NULL)

Arguments

image

(H,W) or (H,W,C) array, passed to model unchanged.

model

Function(image) -> array (H,W,K) scores.

y_true

Optional (H,W) integer (0-based) ground-truth labels.

Value

list with labels, scores, class_counts, iou, mean_iou, pixel_accuracy, confusion, n_classes, estimate, n, method.

Examples

set.seed(6)
model <- function(img) {
  s <- array(rnorm(4 * 4 * 3), c(4, 4, 3))
  s[1:2, , 1] <- 5
  s
}
r <- morie_geron_semantic_segmentation(array(0, c(4, 4, 1)), model)
str(r, max.level = 1)
#> List of 11
#>  $ labels        : int [1:4, 1:4] 0 0 2 1 0 0 1 0 0 0 ...
#>  $ scores        : num [1:4, 1:4, 1:3] 5 5 0.869 1.727 5 ...
#>  $ class_counts  : int [1:3] 10 3 3
#>  $ iou           : NULL
#>  $ mean_iou      : NULL
#>  $ pixel_accuracy: NULL
#>  $ confusion     : NULL
#>  $ n_classes     : int 3
#>  $ estimate      : num 0.625
#>  $ n             : int 16
#>  $ method        : chr "Per-pixel argmax with per-class IoU / pixel accuracy against ground truth"