How to Install LabelImg on Windows

Install LabelImg

LabelImg is a graphical image annotation tool and label object bounding boxes in images.

Why?

Sometimes installations are a painful part when it comes to ai and machine learning.
I decided to write a tutorial to simplify the installation process of LabelImg.
I hope it will help people who are not necessarily technical but need to work with image annotation tool.

Folders stracture

TensorFlow/
├─ addons/
│  └─ labelImg/

Requirements

Python installed.

Download zip file

Download from here:
github.com/tzutalin/labelImg

Install dependencies

pip install lxml

pip install PyQt5

Collecting PyQt5
  Downloading PyQt5-5.15.4-cp36.cp37.cp38.cp39-none-win_amd64.whl (6.8 MB)
     |████████████████████████████████| 6.8 MB 939 kB/s
Collecting PyQt5-Qt5>=5.15
  Downloading PyQt5_Qt5-5.15.2-py3-none-win_amd64.whl (50.1 MB)
     |████████████████████████████████| 50.1 MB 6.4 MB/s
Collecting PyQt5-sip<13,>=12.8
  Downloading PyQt5_sip-12.9.0-cp39-cp39-win_amd64.whl (63 kB)
     |████████████████████████████████| 63 kB 4.8 MB/s
Installing collected packages: PyQt5-Qt5, PyQt5-sip, PyQt5
Successfully installed PyQt5-5.15.4 PyQt5-Qt5-5.15.2 PyQt5-sip-12.9.0

Install

Navigate to folder

C:\>cd TensorFlow
C:\TensorFlow>cd addons
C:\TensorFlow\addons>cd labelImg

pyrcc5 -o libs/resources.py resources.qrc

Open LabelImage


cd C:/TensorFlow/addons/labelImg
python labelImg.py

Note: keep cmd open.
Shortcuts: W – Create RectBox

Result

How to Label Images for Object Detection With Labelimg

 
Labelimg labelling images

Manually labelling images for machine learning is exhausting work, proper use of a good tool can save a lot of headache.

Folders stracture

TensorFlow/
├─ addons/
│  └─ labelImg/

Installation

You can have a look at:
How to Install LabelImg on Windows

Open LabelImg

Open cmd (for Windows users) and right click to paste.
cd C:/TensorFlow/addons/labelImg
python labelImg.py
Note: keep cmd open.

Open images

I usually put all the images in a folder and then load the folder.
LabelImg

Draw a new box

Step 1: select your ‘save format’.
Step 2: Click on ‘Create RectBox’.
Step 3: draw a box (RectBox).
Step 4: Select class (label) from the list (predefined_classes.txt).
LabelImg

Predefined classes .txt file

The ‘predefined_classes.txt’ file contain a list of classes to train your ml model.
Edit this file to have your own classes (labels).

TensorFlow/
├─ addons/
│  └─ labelImg/
│  │  └─ data/
│  │  │  └─ predefined_classes.txt

LabelImg

I will edit the file with classes that fit the model I am developing.
Reopen LabelImg to see the changes.

LabelImg

Labelimg Shortcuts

  • Create RectBox: ‘W’
  • Zoom In: ‘Ctrl’ + ‘+’
  • Zoom Out: ‘Ctrl’ + ‘-‘
  • Save (as xml): ‘Ctrl’ + ‘S’
  • Next Image: ‘D’ (Only when ‘File List’ not empty)
  • Prev Image: ‘A’
  • Delete RectBox: ‘Delete’
  • Edit Label: ‘Ctrl’ + ‘E’

Tips and tricks

Some tips to speed up the process:

  • ‘Open Dir’ instead of ‘Open’.
  • Use shortcuts.
  • Define your own ‘predefined_classes.txt’.
  • I don’t recommend adding new labels while labeling, it’s best that everything is ready in advance.
  • Start labeling on a few pictures and train your model, , before you waste your or others’ time.
  • Don’t be too lazy to zoom.
  • Mark the whole object and give some space in the margins.
  • Double click on class name to select it.
    LabelImg

Save as xml

‘Save’ will generate a file in the same folder with the same name, only with an ‘.xml’ extension.
LabelImg
LabelImg

Result