Skip to content

Instantly share code, notes, and snippets.

@ilyakava
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilyakava/8081abe411df14deadbb to your computer and use it in GitHub Desktop.
Save ilyakava/8081abe411df14deadbb to your computer and use it in GitHub Desktop.
# assumes the images have been downloaded from imagenet and are named:
# bird.tar car.tar circle.tar flower.tar horse.tar house.tar mountain.tar tree.tar woman.tar
TAGS=( car tree circle house mountain bird flower horse woman )
# total=7577
LIMS=( 738 797 836 839 849 853 856 895 914 )
# list contents of tarballs and shave off file extension
for tag in "${TAGS[@]}"; do tar -tf $tag.tar | sed 's/.JPEG$//' > $tag.txt; done
# append my chosen class numbers for each class (hand is the missing #2)
sed -e 's/$/,9/' -i car.txt
sed -e 's/$/,8/' -i tree.txt
sed -e 's/$/,7/' -i circle.txt
sed -e 's/$/,6/' -i house.txt
sed -e 's/$/,5/' -i mountain.txt
sed -e 's/$/,4/' -i bird.txt
sed -e 's/$/,3/' -i flower.txt
sed -e 's/$/,1/' -i horse.txt
sed -e 's/$/,0/' -i woman.txt
# concatenate to a csv
echo "image,tag" > all.csv
for f in $(ls *txt); do cat $f >> all.csv; done
echo "image,tag" > partial.csv
for i in $(seq 0 8); do head -${LIMS[i]} ${TAGS[i]}.txt >> partial.csv; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment