Labelme is one of the most convenient annotation tool for polygon annotation. This article explains how to use labelme for annotation of objects.

Install labelme and its dependencies.

On Windows:

  • pip3 install pyqt5
  • pip3 install labelme

On Ubuntu 14.04 / Ubuntu 16.04:

  • sudo apt-get install python3-pyqt5
  • sudo pip3 install labelme

On Ubuntu 19.10+ / Debian (sid) use:

  • sudo apt-get install labelme

On macOs

  • brew install pyqt5
  • pip3 install labelme

In your PC’s command prompt just type labelme and labelme’s GUI will be displayed as a separate window.

labelme

Labelme GUI displayed

In the GUI interface click on Open Dir, the second-left corner icon to open directory of the images you intend to annotate.

When you click on open Dir you can choose the folder containing the images.

It will show the first image in the folder you selected.

We intend to annotate the squirrel in this image, click on the create polygons, the seventh-left corner icon of the GUI interface. Drag your mouse to the object in the image.

Start annotating by moving the mouse round the object. Please take note of the starting point because we are going to close the polygon at the starting point. The annotation was started at the neck of the squirrel.

Finalize the annotation at the starting point i.e the neck of the squirrel(when you reached the starting point to join the polygon lines it will show this white circle).

Click on the white circle it brings this separate window where it requires you to enter the label name of the object you annotated. I entered the label name squirrel, the name of the object annotated and press OK button.

We finished the polygon annotation of the squirrel, we have to save it. You click the save icon(fifth-left corner icon) to save it.

It saved annotation in a json format. By default the json file is saved in the image name and in the same directory as the image. Do not alter the name of the saved json file and the directory in which it is saved.

We have saved the first image annotated, annotate the next image in the directory by clicking on the next image icon(third-left coner icon)

It brings the second image in the directory, annotate it and repeat the process until all the images in the directory are all annotated.

Note:You should ensure that the images and the json files are saved in the same directory. The train images and json files generated by labelme must be in the same train folder. Do not store the json files in a separate folder and do not change the default name of the json’s file corresponding to the image name. The image and json’s file corresponding to it must have the same name. e.g image.jpg and image.json.

A DeepLearning practitioner. Creator of PixelLib https://github.com/ayoolaolafenwa/PixelLib