Easiest Way to Label Your Images in Python For Free



Original Source Here

When we talk about self-driving cars, face masks detection, activity tracking, object segmentation, number plate detection— every use-case needs labelling of images as a crucial step.

Image labelling is a manual process and needs quality time to complete. Before we start to dig deeper into the image labelling process — let’s first understand what image labelling is and why we need it.

Image labelling is the process of assigning a particular tag to the particular objects present in our images — so that our machine can distinguish among them.

Image labelling is used in the computer vision field. Every object detection system, image segmentation model, activity detection, motion tracker models utilise the image labelling process as an initial step while preparing data for our model.

Now, as you have some idea about image labelling and why we use this image labelling process — let’s now look at the step by step process of labelling our images.

To start with the process, you must have python installed on your machine. And, that’s the only requirement for this task.

Setting up the environment

For our image labelling task — we will be utilising an open-source python package named “labelImg”. This package can help us label our images. This library utilises pyqt5 to provide us with a GUI environment to make our task done.

If you have Git installed in your machine — Run the below command in your command prompt to clone it.

git clone https://github.com/pranjalAI/labelImg.git

If you don’t have the Git install, then you can directly download it from here. Just click on the download button, and the package will get downloaded. Once downloaded, you can unzip it to any folder to use.

Installing the dependencies

We need to install a dependent library named “pyqt5” to make labelImg work. Let’s install it.

  • Open the command prompt.
  • Move to the folder named labelImg — that you have downloaded from the source.
  • Now, run the below command
pip install pyqt5

Setting up the predefined classes

You need to move to the “labelImg\data” folder; there, you will find predefined_classes.txt

You can type your list of objects names that your images have. Every new object should be on the new line.

Screenshot by the author

Running the Package

As this is a python package — we can run it the same way we run any python script. As soon as you run the python scripts (as shown below), a window will open, which is a part of the python UI interface.

There you go! You will now find a new UI window with some functions.

Screenshot by the author

Image Labelling in Action

The goal of this python library is to label our images. You can collect some images in a folder to use. Once the tool gets launch — you can find a few options at the left.

  • Click on the “Open Dir” option and select the folder where you have saved the images you need to label.
  • Now you need to set a path where you want to save your object details. Click on “Change Save Dir” and select a folder to save your object details.
Gif: Recorded by the author

Object detail file contains the coordinate of objects in your image and the label for your image.

Now, to label the displayed images — first, you need to set the label type. You can do it at the bottom left. Here, I am doing it for YOLO object detection, so I have selected accordingly.

And, then you can click on create RectBox button to start drawing the bounding box.

Gif: Recorded by the author

While drawing the bounding box, you can select the class that we have defined before.

Once the labelling process is complete — you can go to the object details folder and will find a separate text file for your images.

Screenshot by author

Here you go! We now have images with their respective label files that we can use for our object detection tasks.

AI/ML

Trending AI/ML Article Identified & Digested via Granola by Ramsey Elbasheer; a Machine-Driven RSS Bot

%d bloggers like this: