AtriSaxena / OIDv4_ToolKit

Download and visualize single or multiple classes from the huge Open Images v4 dataset

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OIDv4 ToolKit for Object Detection

Do you want to build your personal object detector but you don't have enough images to train your model? Have you already discovered Open Images Dataset v4 that has 600 classes and more than 1,700,000 images ready to use? Do you want to exploit it for your projects but you don't want to download more than 500 GB of data!?

With this repository we can help you to get the best of this dataset with less effort as possible. In particular, with this practical ToolKit written in Python3 we give you the following options:

  • download any class of the dataset individually, taking care of creating the related bounding boxes for each downloaded image
  • download multiple classes at the same time creating separated folder and bounding boxes for each of them
  • download multiple classes and creating a common folder for all of them with a unique annotation file of each image
  • download a single class or multiple classes with the desired attributes
  • use the practical visualizer to inspect the donwloaded classes

The code is quite documented and designed to be easy to extend and improve. Me and Angelo are pleased if our little bit of code can help you with your project and research. Enjoy ;)

Snippet of the OIDv4 available classes

Open Image Dataset v4

All the information related to this huge dataset can be found here In these few lines are simply summarized some statistics and important tips.

Images1,743,04241,620 125,436-

As it's possible to observe from the previous table we can have access to images from free different groups: train, validation and test. The ToolKit provides a way to select only a specific group where to search. It's important to underline that some annotations has been done as a group. It means that a single bounding box groups more than one istance. As mentioned by the creator of the dataset:

  • IsGroupOf: Indicates that the box spans a group of objects (e.g., a bed of flowers or a crowd of people). We asked annotators to use this tag for cases with more than 5 instances which are heavily occluding each other and are physically touching. That's again an option of the ToolKit that can be used to only grasp the desired images.

Finally, it's interesting to notice that not all annotations has been produced by humans, but the creator also exploited an enhanced version of the method shown here reported 1

Getting Started


Python3 is required.

  1. Clone this repository
    git clone
  2. Install the required packages
    pip3 install -r requirements.txt

Peek inside the requirements file if you have everything already installed. Most of the dependencies are common libraries.

Launch the ToolKit to check the available options

First of all, if you simply want a quick reminder of al the possible options given by the script, you can simply launch, from your console of choice, the Remember to point always at the main directory of the project


or in the following way to get more information

python3 -h

Use the ToolKit to download

The ToolKit permit the download of your dataset in the folder you want (Datasetas default). The folder can be imposed with the argument --Dataset so you can make different dataset with different options inside.

As previously mentioned, there are different available options that can be exploited. Let's see some of them.

Download different classes in separated folders

Firstly, the ToolKit can be used to download classes in separated folders. The argument --classes accepts a list of classes or the path to the file.txt (--classes path/to/file.txt) that contains the list of all classes one for each lines (classes.txt uploaded as example).

Note: for classes that are composed by different words please use the _ character instead of the space (only for the inline use of the argument --classes). Example: Polar_bear.

Let's for example download Apples and Oranges from the validation set. In this case we have to use the following command.

 python3 downloader --classes Apple Orange --type_csv validation

The algorith will take care to download all the necessary files and build the directory structure like this:

    │   file011.txt
    │   file012.txt
    |    │   class-descriptions-boxable.csv
    |    │   validation-annotations-bbox.csv
        └─── test
        └─── train
        └─── validation
             |     |
             |     |0fdea8a716155a8e.jpg
             |     |2fe4f21e409f0a56.jpg
             |     |...
             |     └───Labels
             |            |
             |            |0fdea8a716155a8e.txt
             |            |2fe4f21e409f0a56.txt
             |            |...

If you have already downloaded the different csv files you can simply put them in the csv_folder. The script takes automatically care of the download of these files, but if you want to manually download them for whatever reason here you can find them.

If you interupt the downloading script ctrl+d you can always restart it from the last image downloaded.

Download multiple classes in a common folder

This option allows to download more classes, but in a common folder. Also the related notations are mixed together with the already explained format (the first element is always the name of the single class). In this way, with a simple dictionary it's easy to parse the generated label to get the desired format.

Again if we want to download Apple and Oranges, but in a common folder

 python3 downloader --classes Apple Orange --type_csv validation --multiclasses 1


In the original dataset the coordinates of the bounding boxes are made in the following way:

XMin, XMax, YMin, YMax: coordinates of the box, in normalized image coordinates. XMin is in [0,1], where 0 is the leftmost pixel, and 1 is the rightmost pixel in the image. Y coordinates go from the top pixel (0) to the bottom pixel (1).

However, in order to accomodate a more intuitive representation and give the maximum flexibility, every .txt annotation is made like:

name_of_the_class left top right bottom

If you don't need the labels creation use --noLabels.

Optional Arguments

The annotations of the dataset has been marked with a bunch of boolean values. This attributes are reported below:

  • IsOccluded: Indicates that the object is occluded by another object in the image.
  • IsTruncated: Indicates that the object extends beyond the boundary of the image.
  • IsGroupOf: Indicates that the box spans a group of objects (e.g., a bed of flowers or a crowd of people). We asked annotators to use this tag for cases with more than 5 instances which are heavily occluding each other and are physically touching.
  • IsDepiction: Indicates that the object is a depiction (e.g., a cartoon or drawing of the object, not a real physical instance).
  • IsInside: Indicates a picture taken from the inside of the object (e.g., a car interior or inside of a building).
  • n_threads: Select how many threads you want to use. The ToolKit will take care for you to download multiple images in parallel, considerably speeding up the downloading process.
  • limit: Limit the number of images being downloaded. Useful if you want to restrict the size of your dataset.

Naturally, the ToolKit provides the same options as paramenters in order to filter the downloaded images. For example, with:

 python3 downloader --classes Apple Orange --type_csv validation --image_IsGroupOf 0

only images without group annotations are downloaded.

Use the ToolKit to visualize the labeled images

The ToolKit is useful also for visualize the downloaded images with the respective labels.

   python3 visualizer

In this way the default Dataset folder will be pointed to search the images and labels automatically. To point another folder it's possible to use --Dataset optional argument.

   python3 visualizer --Dataset desired_folder

Then the system will ask you which folder to visualize (train, validation or test) and the desired class. Hence with d (next), a (previous) and q (exit) you will be able to explore all the images. Follow the menu for all the other options.

Community Contributions

  • Denis Zuenko has added multithreading to the ToolKit and is currently working on the generalization and speeding up process of the labels creation
  • Skylion007 has improved labels creation reducing the runtime from O(nm) to O(n). That massively speeds up label generation
  • Alex March has added the limit option to the ToolKit in order to download only a maximum number of images of a certain class
  • Michael Baroody has fixed the toolkit's visualizer for multiword classes


Use this bibtex if you want to cite this repository:

  title={Toolkit to download and visualize single or multiple classes from the huge Open Images v4 dataset},
  author={Vittorio, Angelo},
  journal={GitHub repository},


"We don't need no bounding-boxes: Training object class detectors using only human verification"Papadopolous et al., CVPR 2016.


Download and visualize single or multiple classes from the huge Open Images v4 dataset

License:GNU General Public License v3.0


Language:Python 100.0%