Building a Dataset: Object Detection


Now that you have identified that an Object Detector is the right option for your use case, you need to collect and prepare your data to train an Object Detector. We'll use the example of detecting when someone is not wearing proper protective equipment from the Use Cases & AI Architectures document to illustrate the process.

Define the Classes

Start by identifying the classes you want your model to predict. This could be a larger object you want to detect in a frame or something small. For our example use case of wanting to detect whether people are compliant in wearing proper protective equipment, we'll focus on detecting people not wearing a high visibility vest.

The detail of detection will depend on the training of the model as well as the resolution and clarity of the images fed to the model. Something larger, like the high visibility vest, will be easier to detect than something like safety glasses.

Collect the Data

Make sure the dataset you are curating represents real-world scenarios for your use case.
This is extremely important for your model performance. If you already have a dataset of images, review them to make sure they represent real-world scenarios.

When collecting data, take into account numerous variables to ensure that your model will have the best data to train on:

  • Lighting settings
  • Image resolution quality
  • Camera angles
  • Backgrounds and environments
  • Images without the object to identify (if needed)
  • Images with both the object and not the object in the same frame (if needed)

For our example use case, we'll want images of people wearing a high visibility vest and images of people not wearing a high visibility vest.

Organize the Data

Once you have your data collected, organize and distribute the images between two folders:

Unlike the Image Classifier dataset, you don't need to organize separate Validation images. Navigator will automatically "create" your Validation images with the training element.

Do this by adjusting the Validation Split slider found in the settings panel for the Object Detection Trainer Element. We recommend starting with 20% Validation Split.

  • 80% Training images

  • 20% Testing images

Annotate the Data

Create a second folder inside your Training images folder and call it "annotations".

Annotate the Data

To train an object detector model, you need to annotate your training dataset so the model knows what to learn and what it's looking for in the image.

  1. Use an annotation tool that allows you to annotate using bounding boxes and can export the annotations in COCO JSON format. We recommend using the MAC application RectLabel Pro.

  2. Draw a bounding box around the objects in the frame of your training images that you want to assign a class to. For this example, you'll want two classes: people wearing a high visibility vest and people not wearing a high visibility vest.

  3. Draw your bounding boxes as close to the edge of the object you want to detect. This will ensure the model trains on just the object you want to detect and not anything in between the edge of the item and the edge of the bounding box.

  4. Once you have annotated your training images, you can move on to training your Object Detector.