Skip to contents

Decodes an (S,S,B\*5+C) prediction tensor (tx,ty,tw,th,conf per box, shared class probs per cell), score = conf*class_prob, greedy per-class NMS at iou_threshold.

Usage

morie_geron_yolo(
  image,
  model,
  n_boxes = 1,
  conf_threshold = 0.5,
  iou_threshold = 0.45
)

Arguments

image

Passed to model unchanged.

model

Function(image) -> array (S,S,B*5+C).

n_boxes, conf_threshold, iou_threshold

As in Python original.

Value

list with boxes, scores, classes (0-based), n_detections, n_candidates, suppressed, grid, n_classes, estimate, n, method.

Examples

set.seed(6)
model <- function(img) {
  P <- array(0, c(2, 2, 7))
  P[1, 1, ] <- c(0.5, 0.5, 0.3, 0.3, 0.9, 3, -3)
  P
}
r <- morie_geron_yolo(array(0, c(4, 4, 1)), model, n_boxes = 1)
str(r, max.level = 1)
#> List of 11
#>  $ boxes       : num [1, 1:4] 0.1 0.1 0.4 0.4
#>  $ scores      : num 2.7
#>  $ classes     : int 0
#>  $ n_detections: int 1
#>  $ n_candidates: int 1
#>  $ suppressed  : int 0
#>  $ grid        : int 2
#>  $ n_classes   : num 2
#>  $ estimate    : num 2.7
#>  $ n           : int 4
#>  $ method      : chr "Grid decode of (x, y, w, h, conf) + class scores, then greedy per-class NMS"