Creating Semantic Segmentation Labels for the Training Data.
Annotating the Images for Training the Models.
IMAGE / LABEL EXAMPLE AS MOTIVATION


One of my Research Topics required some training data, which was not easily available publicly anywhere, and I decided to create a dataset of my own. After a lot of searching I found LabelMe to annotate and label the image.
What is LabelMe :
LabelMe is a tool which is written in Python to annotate an image.
Types of Annotation which can be done in LabelMe :
1. Classification
2. Detection
3. Semantic Segmentation
4. Instance Segmentation
Steps to Install and Run LabelMe :
- It is always suggested to create a new Conda Environment for LabelMe.
conda create -name labeme python=3.6
- Activate the Environment.
conda activate labelme
- Installing the Labelme
pip install labelme
- Run Labelme
labelme
Using LabelMe :
- Once you start labelme by typing the
labelme
command you will see the below image.

- Click on Open (Or Open Dir — If there are multiple images).
- Select the Image you want to annotate.
- Once the image is loaded on LabelMe, click on the Edit button on the Toolbar, this will give you various options to create a shape.

- Start drawing the shape around the object you would like to annotate, use frequent clicks to create the vertices of a shape, and change the direction of the edge. (Note : If you are creating a Polygon, make sure your end point meets the first point)
- Once you are done with creating the shape, a popup will appear, where you can enter the label (class) name.

- Whenever you add a new Label, it will get added to the list, which you can select for multiclass segmentation.
- Once done, click on save and enter the file name and save it. (The extension will be JSON always).
- The JSON output file will have the ImagePath, the shape type, points, the class name and many more information.
- Now either you can use the JSON output file directly to train the data (Based on your preprocessing), or convert the JSON into PNG file (Steps mentioned below).
Steps to convert the JSON output into PNG file :
- Open Anaconda Prompt again.
- Activate the LabelMe environment which you created to install LabelMe.
- Go to the path where the JSON file had been download.
- Run the below command (Replace your file names):
labelme_json_to_dataset your_file_name.json -o output_file_name
- Once done, you will see some info and warning loggers on the command prompt, ending with Saved to : <output_file_name>
- Open the folder and you will see your input image with the label output image (Both in PNG format).
Credits goes to the LabelMe team and more information about LabelMe can be found here