Skip to contents

yolo_dataset_convert() converts annotations from standard computer vision formats into a clean, ready-to-train YOLO dataset. Supports:

  • CSV: Tabular tables (image, xmin, ymin, xmax, ymax, class) commonly exported by ImageJ, Fiji, or field records.

  • COCO: Standard COCO JSON (instances_train.json with images, annotations, categories).

  • Pascal VOC: Directory of XML annotation files.

Automatically computes normalized YOLO coordinates and creates train/ and val/ splits.

Usage

yolo_dataset_convert(
  input,
  format = c("csv", "coco", "voc"),
  img_dir = NULL,
  out_dir = "yolo_converted_dataset",
  split = c(train = 0.8, val = 0.2),
  copy = TRUE,
  seed = 42,
  overwrite = FALSE,
  verbose = TRUE
)

Arguments

input

Path to the annotation file (.csv, .json) or directory containing Pascal VOC .xml files.

format

Format type: "csv" (default), "coco", or "voc".

img_dir

Directory where the raw image files are stored.

out_dir

Destination directory for the YOLO dataset. Defaults to "yolo_converted_dataset".

split

Proportions for train and validation splits (default: c(train = 0.80, val = 0.20)).

copy

Logical. Whether to copy image files into the dataset. Defaults to TRUE.

seed

Random seed for split partitioning (default: 42).

overwrite

Logical. Overwrite existing out_dir. Defaults to FALSE.

verbose

Logical. Show progress. Defaults to TRUE.

Value

A yolo_dataset object pointing to out_dir.

Examples

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

# Convert CSV bounding boxes from field phenotyping
ds_yolo <- yolo_dataset_convert(
  input   = "field_labels.csv",
  format  = "csv",
  img_dir = "field_photos",
  out_dir = "dataset_field_yolo"
)
}