Skip to contents

Provides an ultra-efficient, ergonomic interactive labeling tool for creating and editing YOLO-Pose datasets. Supports three essential labeling strategies:

  1. Auto BBox from Points (box_mode = "auto"): Click only the K keypoints; the bounding box is automatically computed with a configurable padding margin (box_pad). Cuts clicks in half!

  2. Manual BBox + Points (box_mode = "manual"): Click 2 opposite corners for the bounding box, followed by the K keypoints in sequence.

  3. Visibility & Occlusion Control (allow_occlusion = TRUE): Supports marking points as visible (v=2), occluded (v=1), or absent/skipped (v=0) with instantaneous keyboard/right-click shortcuts.

Usage

yolo_dataset_label_pose(
  dir = ".",
  image = NULL,
  kpts = 2L,
  kpt_names = NULL,
  skeleton = NULL,
  box_mode = c("auto", "manual", "prompt"),
  box_pad = 0.1,
  allow_occlusion = TRUE,
  class_names = NULL,
  class_id = 0L,
  split = c("all", "train", "val", "test"),
  resume = TRUE,
  update_yaml = TRUE,
  backup = TRUE,
  split_data = FALSE,
  split_ratio = c(train = 0.7, val = 0.2, test = 0.1),
  rainbow = TRUE,
  pt_cex = 1.8,
  line_lwd = 2,
  verbose = TRUE
)

yolo_pose_label(
  dir = ".",
  image = NULL,
  kpts = 2L,
  kpt_names = NULL,
  skeleton = NULL,
  box_mode = c("auto", "manual", "prompt"),
  box_pad = 0.1,
  allow_occlusion = TRUE,
  class_names = NULL,
  class_id = 0L,
  split = c("all", "train", "val", "test"),
  resume = TRUE,
  update_yaml = TRUE,
  backup = TRUE,
  split_data = FALSE,
  split_ratio = c(train = 0.7, val = 0.2, test = 0.1),
  rainbow = TRUE,
  pt_cex = 1.8,
  line_lwd = 2,
  verbose = TRUE
)

yolo_dataset_pose(
  dir = ".",
  image = NULL,
  kpts = 2L,
  kpt_names = NULL,
  skeleton = NULL,
  box_mode = c("auto", "manual", "prompt"),
  box_pad = 0.1,
  allow_occlusion = TRUE,
  class_names = NULL,
  class_id = 0L,
  split = c("all", "train", "val", "test"),
  resume = TRUE,
  update_yaml = TRUE,
  backup = TRUE,
  split_data = FALSE,
  split_ratio = c(train = 0.7, val = 0.2, test = 0.1),
  rainbow = TRUE,
  pt_cex = 1.8,
  line_lwd = 2,
  verbose = TRUE
)

Arguments

dir

Character or yolo_dataset object. Dataset root directory (containing images/ and labels/ or a flat directory). Default is ".".

image

Optional character vector. Specific image name(s) or file paths to annotate. If NULL (default), iterates through all images in the dataset.

kpts

Integer. Number of keypoints per object (e.g. 2 for log/stick endpoints, 4 for corners/seeds, 5 for facial landmarks, 17 for human pose). Default is 2L.

kpt_names

Character vector. Optional human-readable names for each keypoint (e.g. c("top", "bottom") or c("start", "end")). These names are displayed on the prompt and badge as each point is clicked.

skeleton

Optional list or matrix. Pairs of 1-based keypoint indices to connect with skeleton lines (e.g., list(c(1, 2)) or matrix(c(1, 2, 2, 3), ncol = 2, byrow = TRUE)). If "chain", TRUE, or NULL with kpts >= 2, points are connected sequentially (1-2-3...). Set to FALSE or "none" to disable skeleton lines.

box_mode

Character. How bounding boxes are defined:

  • "auto" (default, Strategy 2): User clicks ONLY the K keypoints. Bounding box is auto-generated enclosing all points + box_pad.

  • "manual" (Strategy 1): User clicks 2 opposite corners to define the bounding box, then clicks the K keypoints.

  • "prompt": Prompts the user per object whether to click a manual box or use auto-box.

box_pad

Numeric or numeric vector of length 2. Margin (relative to box dimension or image size) to expand the bounding box when box_mode = "auto". Default is 0.10 (10% padding). Ensures non-zero width/height even when points are strictly collinear (e.g. 2 endpoints of a line).

allow_occlusion

Logical. If TRUE (default, Strategy 3), allows skipping absent keypoints (v = 0) or marking them as occluded (v = 1) via keyboard/right-click shortcuts (s for skip/absent, o for occluded).

class_names

Character vector. Names of object classes (default: "object").

class_id

Integer. Default class index for newly added objects (default: 0L).

split

Character. Subset to annotate when YOLO folder structure is detected ("all", "train", "val", or "test"). Default is "all".

resume

Logical. If TRUE (default), starts from the first unannotated image in the dataset.

update_yaml

Logical. If TRUE (default), automatically writes/updates kpt_shape: [kpts, 3] and skeleton in data.yaml.

backup

Logical. If TRUE (default), creates a backup (<name>.txt.bak) before saving modifications.

split_data

Logical. If TRUE, splits the annotated images and labels into train/val/test subfolders after labeling according to split_ratio. Defaults to FALSE.

split_ratio

Named numeric vector of proportions for train, val, and test splits when split_data = TRUE. Defaults to c(train = 0.70, val = 0.20, test = 0.10).

rainbow

Logical. If TRUE (default), assigns distinct, harmonious colors to each keypoint.

pt_cex

Numeric. Size of the keypoint circles in the plot (default: 1.8).

line_lwd

Numeric. Line width for skeleton connections and bounding box borders (default: 2.0).

verbose

Logical. If TRUE (default), prints progress and statistics.

Value

An invisible list containing:

total_images

Total number of images inspected

annotated_images

Number of images with annotations

total_objects

Total number of pose objects labeled

kpts

Number of keypoints configured

labels_dir

Path to the labels directory

Examples

if (FALSE) { # \dontrun{
# Label wood logs with 2 keypoints (extremities) using auto-bounding box (only 2 clicks per log!)
yolo_dataset_label_pose("wood_log", kpts = 2, kpt_names = c("end1", "end2"), box_mode = "auto")

# Label plants with 4 keypoints (base, node1, node2, apex) using manual box + occlusion control
yolo_dataset_label_pose(
  "plants",
  kpts = 4,
  kpt_names = c("base", "n1", "n2", "apex"),
  box_mode = "manual"
)
} # }