Custom Vision: Chapter 7 - Object Detection - Data Annotation

Computer Vision Aug 6, 2021

Hello there, welcome to the next chapter on our Custom Vision series. I hope you are enjoying the content and finding it useful to learn all nuances required for AI solution implementation.

In the last chapter, we talked in brief about Object Detection as a Computer Vision solution to perceive images just like humans do. Today we will take the next step in the journey.

To train any model, the most important pre-requisite is "Data". But raw data cannot help us in solving any problem. We need to process it, transform it or add metadata to it in order to make it useful.

What kind of transformation is needed in the Object Detection problem?
Similar to Image Classification, core Object detection logic works on spatial information stored in form of pixel values in an image.

So for our Neural Network to understand these spatial features and distinguish between them, along with the image, we need to provide class metadata of the image to the Network. This process of attaching class metadata to an image is also called Data Annotation.

How do I annotate my images?

You can choose from a variety of tools available in the market which helps you with annotation task. There are both open-source and cloud-native tools available. Which one to use entirely depends on your requirements.

As part of this article, we will be using Label Studio to annotate the image dataset.

If you have missed our earlier posts where we saw how to install and set up Label Studio on your local system, we recommend you to go through the article mentioned below.
Custom NLP: Chapter 2 - Data Annotation using Label Studio
In the previous chapter, we talked in detail about what is Natural Language Processing and we saw that the generic model does not suit all our requirements. Which brought us to the notion of having Custom trained NLP models. We also talked about the various steps involved before we can

Import Data

Once you are done with the installation steps as mentioned in the above post, we can start with the initial steps required to start annotations.

  1. Create new project
  2. Import Data
  3. Select the labeling setup (In our case select Object Detection with Bounding Boxes)
  4. Add your custom labels

Step by step guide is provided in the video below.

We can also sync data directly from cloud storage. Check out options in Label Studio documentation.
Create a new project and add data

Start Annotating

With the project setup done and data imported, it's time to take on to the main task – Drawing annotations on Image. Label Studio provides us with a very intuitive User Interface, that is simple to understand and easy to use.

Just select the class you want to assign to an object, and start drawing a bounding box directly on the image preview. This will draw a colored box on the object you were trying to tag.

You can add multiple classes (Multi-Class Object Detection), or single class (Single Class Object Detection) to the same image.

You can also validate the annotations made on the right-hand side on the same screen.

Draw bounding boxes around the objects in an image

Export Annotations

When you are done with annotating all the images, it's time to export the annotations and use them in our Neural Network. There are various formats you can export the annotation data in.

For the object detection problem set, you might see some new format options unlocked in Label Studio

COCO format

When we export annotation data in COCO format, we get a zip file containing a folder with all the images, and a JSON file that contains all the information about the bounding boxes we just created.

The exported JSON file looks something like this

    "images": [],
    "categories": [],
    "annotations": [],
    "info": {}
  1. "images" tag contains metadata and the path of the image.
  2. "categories" tag consists of all the classes/labels we created.
  3. "annotations" tag stores information about the bounding box we created on the image.
  4. "info" tag stores the metadata of the annotation task.

Pascal VOC XML format

Pascal VOC exports annotation information in XML format. Unlike COCO annotation format, where a single master annotation file is generated, in Pascal VOC, an individual annotation file is created for every image.

To know more about the two annotation formats, click here.
Export the annotation data in the required format

Story So Far

So far we have seen how to generate do annotation and generate a file with all the required information using Label Studio.

Next up we will expand on this topic and see how do we import these annotations on the Google Vertex AI platform and train an Object Detection model.

Stay safe and stay tuned for more informative content.


Arpit Jain

Machine Learning Engineer

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.