LabelImg is a graphical image annotation tool.

It is written in Python and uses Qt as its graphical interface.

Annotations are saved as XML files in PASCAL VOC format, which is the format used by ImageNet. It also supports the YOLO format

Watch the demo video

The installation

Build from the source

Linux/Ubuntu/Mac requires at least Python 2.6 and has been tested using PyQt 4.8. However, Python 3 or later and PyQt5 are strongly recommended.

 

Ubuntu Linux

Python 2 + Qt4

sudo apt-get install pyqt4-dev-tools
sudo pip install lxml
make qt4py2
python labelImg.py
python labelImg.py [IMAGE_PATH] [PRE-DEFINED CLASS FILE]
Copy the code

Python 3 + Qt5 (Recommended)

sudo apt-get install pyqt5-dev-tools
sudo pip3 install -r requirements/requirements-linux-python3.txt
make qt5py3
python3 labelImg.py
python3 labelImg.py [IMAGE_PATH] [PRE-DEFINED CLASS FILE]
Copy the code

macOS

Python 2 + Qt4

brew install qt qt4
brew install libxml2
make qt4py2
python labelImg.py
python labelImg.py [IMAGE_PATH] [PRE-DEFINED CLASS FILE]
Copy the code

Python 3 + Qt5 (Recommended)

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
python3 labelImg.py [IMAGE_PATH] [PRE-DEFINED CLASS FILE]
Copy the code

Python 3 Virtualenv (Recommended)

Virtualenv can avoid a lot of the QT / Python version issues

brew install python3 pip3 install pipenv pipenv --three # or pipenv install pyqt5 lxml pipenv run pip install pyqt5 lxml  pipenv run make qt5py3 python3 labelImg.py [Optional] rm -rf build dist; python setup.py py2app -A; mv "dist/labelImg.app" /ApplicationsCopy the code

Note: The Last command gives you a nice.app file with a new SVG icon in the/Applications folder. You can consider using the following script: build-tools/build-for-macos.sh

Windows

Install Python, PyQt5 and install LXML.

Open CMD and go to the labelImg directory

Pyrcc4 -o line/resources.py resources.qrc for pyQt5, Py QRC python labelImg. Py python labelImg. Py [IMAGE_PATH] [pre-defined CLASS FILE]Copy the code

Windows + Anaconda

Download Anaconda (Python 3+)

Open the Anaconda Prompt and go to the labelImg directory

conda install pyqt = 5
pyrcc5 -o libs / resources.py resources.qrc
python labelImg.py
python labelImg.py [IMAGE_PATH] [PRE-DEFINED CLASS FILE]
Copy the code

Get from PyPI but only python3.0 or higher

Pip3 install labelImg labelImg labelImg [IMAGE_PATH]Copy the code

Using a Docker

-e DISPLAY = Unix $DISPLAY \ --workdir = $(PWD) \ --volume = "/ home / $user: /home/$USER "\ --volume =" /etc/group: /etc/group: ro "\ --volume =" /etc/passwd: /etc/passwd: Ro "\ --volume =" /etc/shadow: /etc/shadow: Ro \ - volume = ""/etc/sudoers. D: / etc/sudoers. D: ro" \ - v/TMP/X11 - Unix: / TMP/X11 - Unix \ tzutalin/py2qt4 make qt4py2 ; ./labelImg.pyCopy the code

You can extract an image with all installed and required dependencies. Watch the demo video

usage

Step (PascalVOC)

  1. Build and start using the above instructions.
  2. Click Change comments folder saved by default in Menu/Files
  3. Click open Directory
  4. Click create RectBox
  5. Click and release the left mouse button to select the area of the rectangular box that you want to annotate
  6. You can use the right mouse button to drag the rectangular box to copy or move it

Comments will be saved to the folder you specify.

You can refer to the hotkeys below to speed up the workflow.

Steps (YOLO)

  1. indata/predefined_classes.txtDefines a list of classes that will be used for training.
  2. Build and start using the above instructions.
  3. Click the “PascalVOC” button at the bottom right of the toolbar under the “Save” button to switch to YOLO format.
  4. You can use Open/OpenDIR to process single or multiple images. When the individual image is complete, click Save.

TXT files in YOLO format will be saved in the same folder as images with the same name. A file named “classes.txt” is also saved in this folder. “Classes.txt” defines the list of class names referenced by the YOLO tag.

Note:

  • Your label list must not change during the processing of the image list. When an image is saved, classes.txt is also updated, while previous annotations are not.
  • The “Default Class” feature should not be used when saved in YOLO format and will not be referenced.
  • When saving to YOLO format, discard the “Difficult” flag.

Create predefined classes

You can edit data/predefined_classes.txt to load predefined classes

hotkey

Ctrl + u Loads all images from the directory
Ctrl + r Change the default comment target directory
Ctrl + s save
Ctrl + d Copies the current label and rectangle
space Marks the current image as verified
w ^ Create a rectangle
d Next picture
a Previous picture
del Deletes the selected rectangle
Press Ctrl + amplification
Ctrl– narrow
Write – left please Keyboard arrow moves the selected rectangle

Verification picture:

When pressing the space bar, the user can mark the image as verified, which will show a green background. This is used when the dataset is automatically created, and the user can then browse through all the images and mark them instead of annotating them.

Difficult:

The difficulty field set to 1 indicates that the object has been annotated as “difficult,” for example, an object that is clearly visible but hard to recognize without taking full advantage of the context. Depending on your deep neural network implementation, you can include or exclude difficult objects during training.

How to contribute

Send a pull request

license

Free software: MIT license

Quote: Tzutalin. LabelImg. Git code (2015). Github.com/tzutalin/la…