Skip to content

Instantly share code, notes, and snippets.

@Framartin
Last active September 2, 2021 22:55
Show Gist options
  • Save Framartin/da5aba2c97c6bddf78414fc98fc5e654 to your computer and use it in GitHub Desktop.
Save Framartin/da5aba2c97c6bddf78414fc98fc5e654 to your computer and use it in GitHub Desktop.
Create a subset of ImageNet (ILSVRC2012) for debug
echo "Create a subset of ImageNet of 2 images per class for debug"
SOURCE="data/ILSVRC2012/train"
DEST="data/ILSVRC2012_samples/train"
SOURCE="data/ILSVRC2012/validation"
DEST="data/ILSVRC2012_samples/validation"
cd "$SOURCE"
for file in */ ; do
echo "copying subdirectory $file to $DEST"
mkdir -p "${DEST}/${file}"
find "$file" -maxdepth 1 -type f -print0 | head -z -n 2 | xargs -0 -r -- cp -t "${DEST}/${file}" --
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment