Created
November 6, 2017 10:48
-
-
Save moskomule/2e6a9a463f50447beca4e64ab4699ac4 to your computer and use it in GitHub Desktop.
tiny imagenet downloader
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
#!/bin/bash | |
# download and unzip dataset | |
#wget http://cs231n.stanford.edu/tiny-imagenet-200.zip | |
unzip tiny-imagenet-200.zip | |
current="$(pwd)/tiny-imagenet-200" | |
# training data | |
cd $current/train | |
for DIR in $(ls); do | |
cd $DIR | |
rm *.txt | |
mv images/* . | |
rm -r images | |
cd .. | |
done | |
# validation data | |
cd $current/val | |
annotate_file="val_annotations.txt" | |
length=$(cat $annotate_file | wc -l) | |
for i in $(seq 1 $length); do | |
# fetch i th line | |
line=$(sed -n ${i}p $annotate_file) | |
# get file name and directory name | |
file=$(echo $line | cut -f1 -d" " ) | |
directory=$(echo $line | cut -f2 -d" ") | |
mkdir -p $directory | |
mv images/$file $directory | |
done | |
rm -r images | |
echo "done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment