Getting images from Image-Net.org

moshe roth
Jul 27, 2017 · 2 min read
some image-net thumbnails

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.

moshe roth

Written by

I love technology and people. I’m extremely fond of products that disrupt markets and use data to do so

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade