Skip to content

Instantly share code, notes, and snippets.

@moskomule
Created November 6, 2017 10:48
Show Gist options
  • Star 49 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save moskomule/2e6a9a463f50447beca4e64ab4699ac4 to your computer and use it in GitHub Desktop.
Save moskomule/2e6a9a463f50447beca4e64ab4699ac4 to your computer and use it in GitHub Desktop.
tiny imagenet downloader
#!/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