Created
July 9, 2018 18:25
-
-
Save CraigglesO/c96a33ad0e3e26886bb113193c80c607 to your computer and use it in GitHub Desktop.
Find the differences between images and labels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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