Last active
March 23, 2018 04:37
-
-
Save brookisme/54c5f0014acaa4c63c1260de354b35c1 to your computer and use it in GitHub Desktop.
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
# | |
# add to bashrc | |
# | |
# files | |
alias sampletree='mkdir -p sample/{train,test,valid}' | |
lsn(){ matchdir=`pwd`/$2; find $matchdir -type f | grep -v sample | shuf -n $1 | awk -F`pwd` '{print "."$NF}' ; } | |
# shuffle mv/cp | |
cpn(){ matchdir=`pwd`/$2; find $matchdir -type f | grep -v sample | shuf -n $1 | awk -F`pwd` '{print "."$NF" sample"$NF}' | xargs -t -n2 cp ; } | |
mvn(){ matchdir=`pwd`/$2; todir=`pwd`/$3; find $matchdir -type f | grep -v sample | shuf -n $1 | awk -F`pwd` -v todir="$todir" '{print $0" "todir}' | xargs -t -n2 mv ; } | |
# head mv/cp | |
cpnh(){ matchdir=`pwd`/$2; find $matchdir -type f | grep -v sample | head -n $1 | awk -F`pwd` '{print "."$NF" sample"$NF}' | xargs -t -n2 cp ; } | |
mvnh(){ matchdir=`pwd`/$2; todir=`pwd`/$3; find $matchdir -type f | grep -v sample | head -n $1 | awk -F`pwd` -v todir="$todir" '{print $0" "todir}' | xargs -t -n2 mv ; } | |
# tail mv/cp | |
cpnt(){ matchdir=`pwd`/$2; find $matchdir -type f | grep -v sample | tail -n $1 | awk -F`pwd` '{print "."$NF" sample"$NF}' | xargs -t -n2 cp ; } | |
mvnt(){ matchdir=`pwd`/$2; todir=`pwd`/$3; find $matchdir -type f | grep -v sample | tail -n $1 | awk -F`pwd` -v todir="$todir" '{print $0" "todir}' | xargs -t -n2 mv ; } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dogs and cats example
Assuming you are in the data directory with your test/valid/train directories already set up:
$ sampletree $ mkdir sample/train/{dogs,cats} sample/valid/{dogs,cats} $ cpn 200 train/dogs $ cpn 200 train/cats $ cpn 200 valid/dogs $ cpn 200 valid/cats $ cpn 500 test
Similarly you can use the
mvn
command to set up your original training and validation sets.