Annotation using LabelImg Tool
Getting the coordinates ready for the ‘object identification model’ to learn from images.
The task of annotating the images for the task of training a machine learning/deep learning model falls under the data preparation stage.
(Note :- These data will already be collected by means of camera/etc in the data collection phase )
You need to annotate(draw a bounding box) the object in every single frame.
Although there are many ways for object annotation. I have explained in brief about ‘LabelImg’ — Open source Annotation tool.
Saving the image data-set in a folder (Adding classes.txt)
- Copy all your photos/images/frames to be annotated into one folder
- Create a text file named ‘ classes.txt ’.
- Add all the desired labels/classes in this file in separate lines.
LabelImg — An open source tool for image annotation
An open source tool called labelImg is a tool that can be used for image annotation. You need to clone the repository in your computer and follow the instructions from the repository.
Clone labelImg GitHub repository to your local system.
- Open command prompt and move to the desired folder.
- Use ‘ git clone https://github.com/tzutalin/labelImg.git ’ command to clone the repository to your local system.
- Follow the instructions in repository to install the dependencies for your desired operating system.
- After the repository is cloned, the files will be listed in your local system.
(We will be only working with data folder and ‘labelImg.py’ file, others are left untouched)
- Move inside data folder.
- Open the ‘predefined_classes.txt’ and delete all the contents of the file.
- Now add your desired labels/classes(which you will be annotating in your images) in separate lines and save the file.
(IMPORTANT :- This should be the same classes which was in the classes.txt file we created above in data-set folder)
Now open ‘labelImg.py’ file (wait until labelImg -GUI gets opened)
- Use ‘Open Dir’ option and open the saved data-set folder.
- Use ‘Create RectBox’ option to draw a bounding box around the object in the current image.
- You will be prompted to select a label for the object which is surrounded by current bounding box. Select the appropriate label/class.
- You can annotate multiple objects in a single image.
- You can see the list of objects annotated in right pane.
- Use the ‘Save’ option and save the generated text file(name of the text file will be same as the image name but with txt extension) in the same data-set folder.
- Repeat the same steps to annotate all the images.
Don’t forgot to upload your completed data-set folder(consisting of both images and text files) to your google drive.
Pros:-
1. Backup from data loss.
2. Easy to import and work with data-set in ‘google colab’.
Useful links :-
1) labelImg GitHub repository
2) YouTube Reference