
Perceptual Deduplication and Cross-Split Data Leakage Detection
Source:R/utils_yolo_dataset.R
yolo_dataset_dedup.Rdyolo_dataset_dedup() computes ultrarrápido 64-bit Perceptual Difference Hashes (dHash)
using native OpenMP C++ to identify near-duplicate images within and across YOLO dataset splits.
Crucially, it detects Cross-Split Data Leakage (where near-identical frames or drone photos
leak between train/ and val/ or test/), which artificially inflates validation metrics (mAP).
Usage
yolo_dataset_dedup(
data,
threshold = 4L,
action = c("report", "quarantine", "remove"),
check_leakage = TRUE,
target_split = c("val", "test", "train", "both"),
quarantine_dir = NULL,
num_threads = 0L,
verbose = TRUE
)
yolo_dataset_deduplicate(
data,
threshold = 4L,
action = c("report", "quarantine", "remove"),
check_leakage = TRUE,
target_split = c("val", "test", "train", "both"),
quarantine_dir = NULL,
num_threads = 0L,
verbose = TRUE
)Arguments
- data
A
yolo_datasetobject or directory path.- threshold
Integer (0-64). Maximum Hamming distance to consider two images as near-duplicates (default:
4L, corresponding to \(\ge 93.8\%\) perceptual visual similarity). Distance 0 denotes exact duplicates.- action
Action to execute:
"report"(default, displays analysis without altering files),"quarantine"(moves leaking or duplicate images and labels to a separate directory), or"remove"(deletes duplicate/leaking files from the target split).- check_leakage
Logical. Whether to inspect and flag cross-split leakage (
trainvsval/test). Defaults toTRUE.- target_split
Character specifying which split to act upon when
action = "quarantine"or"remove":"val"(default, cleans validation leaks preserving train),"test","train", or"both".- quarantine_dir
Optional directory path for quarantined files. Defaults to
<dataset>/quarantine.- num_threads
Integer. Number of OpenMP threads for C++ execution (default:
0L, auto-detect all CPU cores).- verbose
Logical. Whether to show progress messages (default:
TRUE).