
Merge Multiple YOLO Datasets with Class Conflict Resolution
Source:R/utils_yolo_dataset.R
yolo_dataset_merge.Rdyolo_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_datasetobjects.- 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. IfFALSE, moves files usingfile.rename().- overwrite
Logical. If
TRUE, overwritesout_dirif it exists. Defaults toFALSE.- 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 |>).