Sitemap

Data Annotation Object Detection (YOLO)?

4 min readMay 15, 2021

--

Object detection is a very famous task these days. Also, it’s the backbone for many computer vision tasks, which include object segmentation, object tracking, object classification, object counting, etc.

If we want to train our algorithm for detecting some objects (i.e. cars), we need to first tell the algorithm about every car present inside training data in the form of a label file.

There are many object detection algorithms, but the most used algorithms include,

  • SSD (Single-shot detector)
  • YOLO (you only look once)
  • Fast R-CNN

In this article, we will focus on Yolo labeling, which accepts a label in the txt file. Other object detectors need a label file but their label files are in different formats.

we will use a labeling tool for labeling data. You need to download the full GitHub repository from the link.

Press enter or click to view image in full size
labeling Tool download

Once downloaded, then extract it in the same folder.

Labeling tool extracted successfully

Note: If you have an anaconda installed then you can continue, otherwise, you first need to install an anaconda from the link.

Now, open the extracted folder. Open an anaconda command prompt and then move to the extracted folder with (cd command).

Press enter or click to view image in full size
Opening the anaconda prompt in the extracted folder

Window Users (commands to build labeling tool)

For pyrcc4 use this command,
pyrcc4 -o libs/resources.py resources.qrc
For pyrcc5 use this command,
pyrcc5 -o libs/resources.py resources.qrc
python labelImg.py

If all the above commands run successfully, you will be able to see the GUI of the labeling tool.

Press enter or click to view image in full size
Command execution
Press enter or click to view image in full size
labeling Tool GUI

Linux Users (commands to build labeling tool)

sudo apt-get install pyqt5-dev-tools
sudo pip3 install -r requirements/requirements-linux-python3.txt
make qt5py3
python3 labelImg.py

If all the above commands run successfully, you will be able to see the GUI of the labeling tool.

Press enter or click to view image in full size

Mac Users (commands to build labeling tool)

brew install qt  # Install qt-5.x.x by Homebrew
brew install libxml2

or using pip

pip3 install pyqt5 lxml # Install qt and lxml by pip

make qt5py3
python3 labelImg.py

If all the above commands run successfully, you will be able to see the GUI of the labeling tool.

Press enter or click to view image in full size

Our labeling tool installed successfully, let’s start labeling on images.

Step-1

Download some images from Google and store them in some folder.

Press enter or click to view image in full size
Dataset visualization

Step-2

Now, open the stored images folder in the labeling tool. for this to be done, you need to open the GUI of the labeling tool and then select the open dir option.

Press enter or click to view image in full size
The dataset inside the labeling tool

Step-3

Now, we need to label the image by selecting the Create RectBox option, dragging on the car area, and then selecting the label car.

Press enter or click to view image in full size
Label Image

Step-4

Now, that we labeled our image successfully, we can save it with (CTRL+S). and it will create a text file of the same name as the image name in the same folder.

Press enter or click to view image in full size
Label files

Now, we can check any text file for verification.

Yolo Format:

<object-class> <x> <y> <width> <height>
Txt file

In the above picture,

  • 4 is class_id
  • 0.494545 is the x-axis value
  • 0.521858 is the y-axis value
  • 0.770909 is the width of an object
  • 0.551913 is the height of an object.

That is all regarding the annotation of data in Yolo format. you can try it on your data.

Dataset creation from videos: Article Link

About Me

  • Muhammad Rizwan Munawar is a highly experienced professional with more than three years of work experience in Computer Vision and Software Development. He is working as a Computer Vision Engineer and has knowledge and expertise in different computer vision techniques including Object Detection, Object Tracking, Pose Estimation, Object Segmentation, Segment Anything, Python, and Software Development, Embedded Systems, Nvidia Embedded Devices. In his free time, he likes to play online games and enjoys his time sharing knowledge with the community through writing articles on Medium.

Please feel free to comment if you have any questions 🙂, If you like the article, Let’s connect on LinkedIn :) 👇

--

--

Muhammad Rizwan Munawar
Muhammad Rizwan Munawar

Written by Muhammad Rizwan Munawar

Passionate Computer Vision Engineer | Solving Real-World Challenges🔎| Python | Published Research | Open Source Contributor | GitHub 🌟 | Top Rated Upwork 💪

Responses (2)