How to install and use labelImg

Introduction

In order to perform object detection using deep learning such as YOLO, a training image dataset is required. In other words, it is necessary to prepare information on “what” is in “what part” of the image.

The tool labelImg makes it easy to create such a training image dataset.

This article describes how to install and use labelImg.

▼The dataset was actually created using labelImg, and YOLO training was performed here.

Installation of labelImg (Windows, Linux)

For Windows and Linux, download the latest package (version at the bottom of the page) from the link below and unzip it.

https://tzutalin.github.io/labelImg/

Then, in the expanded folder

./labelimg

Installation of labelImg (Mac)

Clone the labelImg repository and install the necessary libraries.

git clone https://github.com/tzutalin/labelImg.git
cd labelImg

brew install qt
brew install libxml2
pip install pyqt5 lxml
make qt5py3

Then, after that.

python labelImg.py

How to use labelImg

This time, we will use this image to create training data.

The required labels are

• lion
• tiger

1. First, we need to specify the list of labels to be used for training.

Rewrite “data/predefined_classes.txt” in the folder where labelImg is installed with the required set of labels.

2. Run labelImg.

3.Click on “Open Directory” and specify the directory where the target image is located. The images stored in that directory will then be loaded.

4. Since we will be creating a dedicated dataset to study with YOLO, click on “PascalVOC” under the “Save” button in the sidebar and change it to “YOLO”. Then, select a rectangle and label for the image from “Create Rectangle” in the lower left corner of the sidebar.

5. Finally, save the data from the “Save” button to complete the training data.

When the save is complete, a new “classes.txt” and “lion_tiger.txt” (txt file with the same name as the image) will be created in the directory where the target image is located.

What is important is the latter file, which contains information on “what” is in “what part” of the image.

Also, the shortcut keys for labelImg are as follows (Ctrl → Command⌘ for mac).

Now we can use deep learning such as YOLO to learn object detection.