Skip to contents

yolo_dataset_merge() combines two or more YOLO datasets (Detection, Segmentation, or Classification) into a single, cohesive, conflict-free master dataset. It handles filename collisions by prepending dataset prefixes, harmonizes class indices across differing data.yaml definitions (with optional custom class renaming via class_map), updates label files on-the-fly, and generates a unified master data.yaml.

Usage

yolo_dataset_merge(
  datasets,
  out_dir = "merged_yolo_dataset",
  class_map = NULL,
  copy = TRUE,
  overwrite = FALSE,
  parallel = TRUE,
  num_threads = 0,
  verbose = TRUE
)

Arguments

datasets

A list or character vector of dataset directory paths or yolo_dataset objects.

out_dir

Output directory path for the merged dataset. Defaults to "merged_yolo_dataset".

class_map

Optional named list or vector mapping old class names to unified names (e.g., list("cerca" = "fence", "folha" = "leaf")).

copy

Logical. If TRUE (default), copies files. If FALSE, moves files using file.rename().

overwrite

Logical. If TRUE, overwrites out_dir if it exists. Defaults to FALSE.

parallel

Logical. Whether to use parallel multithreading for file copying and label remapping (default: TRUE).

num_threads

Integer. Number of OpenMP threads to use (default: 0, uses all available CPU cores).

verbose

Logical. Whether to show progress. Defaults to TRUE.

Value

A yolo_dataset object pointing to out_dir (ready for yolo_train() or piping |>).

Examples

if (FALSE) { # interactive()
library(pliman)

# Merge two datasets collected from different seasons
ds_total <- yolo_dataset_merge(
  datasets = list("dataset_2024", "dataset_2025"),
  out_dir  = "dataset_unificado"
)
}