Skip to contents

Applies a trained yolo_fewshot_model to detect and segment instances in a new image.

Usage

yolo_fewshot_predict(
  model,
  img,
  task = model$task,
  conf_threshold = NULL,
  max_objects = NULL,
  engine = "gpu",
  device_id = -1,
  plot = FALSE,
  rainbow = TRUE,
  show_class = if (!is.null(model$show_class)) model$show_class else TRUE,
  show_conf = if (!is.null(model$show_conf)) model$show_conf else TRUE,
  badge = if (!is.null(model$badge)) model$badge else TRUE,
  lower_size = NULL,
  upper_size = NULL,
  size_mode = c("relative", "absolute"),
  ...
)

Arguments

model

A yolo_fewshot_model fitted via yolo_fewshot_fit().

img

An image object or file path to evaluate.

task

Task override: "segment" (polygons) or "detect" (bounding boxes). Defaults to model$task.

conf_threshold

Numeric scalar override for detection confidence. Defaults to model threshold.

max_objects

Maximum number of instances to detect.

engine

Execution engine: "cpu" or "gpu". If NULL, uses model$engine.

device_id

GPU device ID if engine = "gpu". Defaults to -1.

plot

Logical. Display detection results. Defaults to FALSE.

rainbow

Logical. If TRUE, plots instances in distinct rainbow colors. Defaults to FALSE.

show_class

Logical. Whether to display class name on labels/badges. Defaults to TRUE.

show_conf

Logical. Whether to display confidence score on labels/badges. Defaults to TRUE.

badge

Logical. Whether to draw a filled background badge behind labels. Defaults to TRUE.

lower_size

Numeric scalar or NULL. Minimum bounding-box area threshold for keeping detections. Interpreted according to size_mode. Defaults to NULL (no lower filter).

upper_size

Numeric scalar or NULL. Maximum bounding-box area threshold for keeping detections. Interpreted according to size_mode. Defaults to NULL (no upper filter).

size_mode

Character string. Controls how lower_size and upper_size are interpreted: "relative" (default, multiplier of mean detected bounding-box area) or "absolute" (pixel area).

...

Additional arguments passed to plotting methods or aliases (e.g. show_labels, show_scores, label_box).

Value

A list containing boxes (bounding boxes data.frame) and polygons (list of normalized coordinates).