Labelling Images for Object Detection with LabelImg

LabelImg is a graphical image annotation tool which allows you to draw visual boxes around your objects in each image, it also automatically saves the XML files of your labelled images. It is a free and easy way to label your images.

Install LabelImg

If you are using Python 3, the easiest way to install LabelImg is using pip. Simply open your command line and run: ‘pip3 install labelImg’. To launch, run ‘labelImg’ in your command line prompt.

Organise your dataset

Once you have opened LabelImg:

  1. Create a folder titled “images” and copy all of your images there
  2. Create another folder titled “annotations”
  3. Go to the LabelImg “View” menu and check that “Auto Save Mode” is selected
  1. Click on “Open Dir” on the left hand side and select your “images” directory
  1. LabelImg will then ask where to save annotations to, select your “annotations” directory.
  2. If no image comes up click the “Next Image” button a few times and it should begin to flick through your images.
  1. Before labelling your images, check which label file format you would like to use. VOC XML is a more of a universal standard when it comes to object detection. LabelImg also supports YOLO format if you would prefer to use that. To change just click on the “</> PascalVOC” or “YOLO” box on the left hand side.

Annotating your Dataset

You are all set up to begin labelling your images now. In this example, we’re using the Kaggle cats v dogs dataset.

Begin annotating your images by:

  1. Click on the “Create n\RectBox”
  1. Use your mouse to draw a box around the object you are wanting to label
  2. Enter the name of the object in the pop-up box and select “OK”
  1. If there is more than one object in the picture select “Create \nRectBox” again and annotate all the objects
  2. Click on the “Next Image” button and repeat the process until you are finished annotating all your images. All the image annotations will be automatically saved in your “annotations” folder. They will be xml files with names corresponding to your image names.

Best Practices

  1. Label the whole object. It is better to include a buffer than to cut out part of the object you are labelling.
  2. If an object is obscured by another object, label it as if you can see the full object. This helps the model to understand the actual size and area of the object.
  3. If an object is partially out of the frame, label them anyway.

If you’re interested in this topic, you can watch the recording of the Data4Good Webinar, where Phoebe talked about the technology used in this project and what they hope to achieve as a long term goal.

Watch the recording here

Share

Facebook
Twitter
LinkedIn
WhatsApp

Leave a Reply

Your email address will not be published.

Recent

Connect with us

If you’d like to be kept in the loop on courses, events and other related topics, simply complete your details and we’ll add you to our list.

We use cookies to improve your experience and support our mission.
Read more about it here. By using our sites, you agree to our use of cookies.