Skip to contents

The model returns [class scores..., x, y, w, h] per image. One head is scored in nats and the other in squared pixels, so alpha is what makes the two comparable. Boxes are centre-form and converted to corners for the IoU.

Usage

morie_geron_classification_localization(
  image,
  model,
  n_classes = NULL,
  gt_class = NULL,
  gt_box = NULL,
  alpha = 1
)

Arguments

image

Passed straight to model.

model

Function of image returning a vector or (B, K+4) matrix.

n_classes

Optional K.

gt_class

Optional 0-based labels.

gt_box

Optional ground-truth boxes.

alpha

Loss weight.

Value

List with class_probs, log_probs, predicted_class (0-based), box, box_corners, iou, loss, loss_class, loss_box, alpha, n_classes, estimate, n.

Examples

model <- function(img) c(2, -1, 0.5, 0.4, 0.4, 0.3, 0.3)
r <- morie_geron_classification_localization(array(0, c(4, 4)), model,
                                             n_classes = 3)
str(r, max.level = 1)
#> List of 14
#>  $ class_probs    : num [1, 1:3] 0.7856 0.0391 0.1753
#>  $ log_probs      : num [1, 1:3] -0.241 -3.241 -1.741
#>  $ predicted_class: int 0
#>  $ box            : num [1, 1:4] 0.4 0.4 0.3 0.3
#>  $ box_corners    : num [1, 1:4] 0.25 0.25 0.55 0.55
#>  $ iou            : NULL
#>  $ loss           : NULL
#>  $ loss_class     : NULL
#>  $ loss_box       : NULL
#>  $ alpha          : num 1
#>  $ n_classes      : int 3
#>  $ estimate       : num 0.786
#>  $ n              : int 1
#>  $ method         : chr "two-headed classification+localization output with cross-entropy, box MSE and IoU"