AutoLabelme is an open-source automatic image annotator created using the Tkinter library in Python. It's an extension of LabelMe, the open-source Image Annotator available in Github LabelMe. It matches the template provided by the user in an image and find same objects associating a bounding box and label for every object. Autolabelme uses Normalized Cross-Correlation to check whether two templates are similar. It is designed keeping in mind with the necessity of creating dataset for object detection purposes and currently can only find objects in the cropped image i.e the search space to find same object is the space around the current template.
- Open
Terminaland rungit clone https://github.com/SadilKhan/AutoLabelMe.git. - Install labelme. Check here for more details.
- Run
labelmeorpython3 /path/to/labelme.pyinTerminal. - Create one bounding box per label.
- Run AutoLabelme.py
python3 /path/to/AutoLabelme.py. - Open JSON and press
Next Line >>for starting to match. - The Left Image will show the boxes for current Label. The smaller right image is for showing all the templates.
- Press
<< Previous Linefor viewing the matched boxes for the previous label. - Press
+for more boxes and-for less boxes or box repositioning. - If you have rotated image, fill the rotation range or just enter
minvalue. For examplemin=45andmax=90will givelist(range(45,94,5))values or just entermin=45which will only rotate the image once (45 degree). - The
search space valueis by default 2 which means the algorithm will check for the templates from two heights up to two heights down in the original image. Choose any value from 1 to 15. For example if your template starts from(200,200)and height and width is 100 and 100 respectively and search space=2, the algorithm will search for the template from(:,0)to(:,400)in the image. If you select more than 15 than it's justheights-the value. For example, if you choose 100 in the previous example, the it will be(:,100)to(:,300)where the templates will be searched in the image. In any case, value from 1 to 15 is sufficient. - Press
Rematchbutton or PressEnterorReturnin your keyboard. - (Optional) Sometimes if the template is symmetric, the algorithm picks up some templates as flipped, to fix this, press
Correct Label. - Press
Save JSONto save a json file. - Open the saved json file in Labelme. Labelme will show the matched templates. Edit it if necessary.
- Press
Save Imagesin AutoLabelme if all the boxes are okay. This will save the matched templates in JPEG.
Next Line >>: Template matching for next label<< Previous Line: Template Matching for the previous label-: Increases the threshold which results in less number of boxes.+: Decreases the threshold which results in more number of boxes.Save JSON: Saves a JSON file which can be read by LabelMe for further edits.Save Images: Save the cropped vignettes from the imagemin: The minimum value for Rotation.max: The maximum value for Rotation.Rematch: Match again for current label.Correct Label: Transform all the boxes to red boxes(no flip).
- Numpy (
pip install numpy) - OpenCV(
pip install opencv-python) - PIL (
pip install pillow) - tkinter (
pip install tk) - colorsys (
pip install colorsys) - tkmacosx (
pip install tkmacosx) --> (ONLY FOR MAC USERS) - labelme (
pip install labelme)[WINDOWS/LINUX] (brew install labelme)[MAC]
templatematcher.py--> Matches templates for specified labels or all the labels. Requires JSON file created using Labelme.templatesaver.py--> Saves the matched images.