Skip to content

Instantly share code, notes, and snippets.

@CraigglesO
Created July 9, 2018 18:25
Show Gist options
  • Save CraigglesO/c96a33ad0e3e26886bb113193c80c607 to your computer and use it in GitHub Desktop.
Save CraigglesO/c96a33ad0e3e26886bb113193c80c607 to your computer and use it in GitHub Desktop.
Find the differences between images and labels
const fs = require('fs');
const IMAGES = {};
const LABELS = {};
console.log("HERE WE GO");
let folders = fs.readdirSync('./dataset/training/images/19');
// grab all pertaining folders ingoring DS_Store
folders.forEach(folder => {
if (folder !== '.DS_Store') {
IMAGES[`${folder}`] = [];
let files = fs.readdirSync(`./dataset/training/images/19/${folder}`);
files.forEach(file => {
if (file !== '.DS_Store') {
IMAGES[`${folder}`].push(file.split('.')[0]);
}
});
}
});
folders = fs.readdirSync('./dataset/training/labels/19');
// grab all pertaining folders ingoring DS_Store
folders.forEach(folder => {
if (folder !== '.DS_Store') {
LABELS[`${folder}`] = [];
let files = fs.readdirSync(`./dataset/training/labels/19/${folder}`);
files.forEach(file => {
if (file !== '.DS_Store') {
LABELS[`${folder}`].push(file.split('.')[0]);
}
});
}
});
Object.keys(IMAGES).forEach(folder => {
if (LABELS[folder]) {
let res = LABELS[folder].filter(f => !IMAGES[folder].includes(f));
if (res.length)
console.log(`folder ${folder} has more data in "labels": `, res);
res = IMAGES[folder].filter(f => !LABELS[folder].includes(f));
if (res.length)
console.log(`folder ${folder} has more data in "images": `, res);
} else {
console.log("Labels does not have folder:", folder);
}
});
Object.keys(LABELS).forEach(folder => {
if (!IMAGES[folder])
console.log("Images does not have folder: ", folder);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment