Getting images from Image-Net.org

During my work I found it useful to create several scripts to help me get my images from Image-Net.org in an organized fashion. The format and hierarchy of directories is important due to Keras image preprocessing logic that I’d like to use later.
My scripts are using ImageNet_utils open source code. Eventually what you’ll get is a data directory with directories full of images, named according to the class name you choose.
Get the original code on my github, and change it to what you need. Read below how to find the class IDs to put in your script (wnid).
#!/bin/bash
imagenet_dir="imagenet_utils"
echo "Get the imagenet_utils repository"
if [ ! -d $imagenet_dir ]; then
git clone https://github.com/tzutalin/ImageNet_Utils.git imagenet_utils
else
echo "imagenet_utils already exists!"
fi
cd $imagenet_dir
echo "Downloading images: face"
class_name="face"
class_wnid="n09618957"
./downloadutils.py --downloadImages --wnid $class_wnid
mv $class_wnid/"$class_wnid"_urlimages ../data/$class_name
echo "find images under ../data/$class_name"
echo "Downloading images: bird"
class_name="bird"
class_wnid="n01503061"
./downloadutils.py --downloadImages --wnid $class_wnid
mv $class_wnid/"$class_wnid"_urlimages ../data/$class_name
echo "find images under ../data/$class_name"in this script. replicate the last code chunks of “Downloading images: ***” for each class of images you want. change the class_name and class_wnid.
How to find the class_wnid?
Go to image-net.org find what you need for example search for “birds”. On the results, click on what you prefer to use and look in the url, it contains the wnid. Paste it to your script.
