This article is available in: 日本語
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.
Then, in the expanded folder
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.
How to use labelImg
This time, we will use this image to create training data.
The required labels are
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).
|Ctrl + u||Load all images from directory|
|Ctrl + r||Change default annotation target directory|
|Ctrl + s||Save|
|Ctrl + d||Copy current label and rect box|
|Ctrl + Shift + d||Delete current image|
|space||Flag the current image as verified|
|w||Create a rectangular box|
|del||Delete selected rect boxes|
|↑→↓←||Move selected rect box with arrow keys|
Now we can use deep learning such as YOLO to learn object detection.
▼ Click here to learn more about YOLO