## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ## ----eval = FALSE------------------------------------------------------------- # library(leakaudit) # # # 1. Hash every image and record which split it currently belongs to # hashes <- compute_hashes( # paths = image_paths, # split = split_labels # ) # # # 2. Cluster images into near-duplicate groups # grouped <- find_duplicate_groups(hashes, threshold = 5) # # # 3. Audit: how much leakage is there? # report <- dhash_audit(grouped) # print(report) # # # 4. Clean: reassign leaked groups to a single split # clean <- clean_splits(grouped, priority = c("train", "val", "test")) ## ----------------------------------------------------------------------------- library(leakaudit) groups <- data.frame( path = c("a.jpg", "b.jpg", "c.jpg", "d.jpg", "e.jpg"), split = c("train", "test", "train", "val", "test"), group_id = c(1, 1, 2, 3, 3), stringsAsFactors = FALSE ) report <- dhash_audit(groups) report ## ----------------------------------------------------------------------------- clean_splits(groups)