Quickly annotate many images, one landmark at a time
Below, I am marking the location of the left corner of the mouth of the person in the image.
It usually takes me less than 3 minutes to annotate 100 images. (The images in the demo are generated by stylegan2 and all have the mouth in a similar location. In this case it takes me only around 2 minutes to annotate 100 images).
You likely want to have multiple landmarks per image (e.g. also location of eyes and nose). With this tool, you need to annotate each image multiple times, once per landmark. So multiply those 3 minutes by the number of different landmarks you want to annotate.
The tool is completely agnostic to the types of landmarks you want to add, i.e. does not have to be face landmarks. You just set a name for your landmark and get clicking.
Most annotation tools work on a per-image basis, i.e. you at once add all annotations (bounding boxes, tags, landmarks, etc) to an image.
I prefer to work on a per-task basis, i.e. only doing one type of annotation (in this case one type of landmark) for all images. Of course, that means haveing to do multiple passes through the images if I want multiple landmarks. For me, avoiding the task-switching in my brain and in the UI is still worth it.
If you also like to work on a per-task basis, then this might be the right tool for you.
Python>=3.7
pip install -r requirements.txt
cp config.py.sample config.py
The directory where the images you want to annotate are located.
- Only .png and .jpg are supported
- Subfolders are not supported, i.e. all images must lie directly in IMAGE_DIR
The directory where the annotations will be stored. Will be automatically created if it does not exist.
The name of the landmark you want to annotate. (e.g. in the video above, LANDMARK=mouth_left).
- Start the annotation server
python start.py
- Open your browser at http://localhost:5000 and start annotating.
You can supply an alternative hostname and port to start.py
.
You can stop annotating at any point in time and switch to a different landmark type.
CTRL+C
to stop the annotation server- Change
config.py
to new landmark name python start.py
- Navigate to http://localhost:5000
You can go also change to the previous landmark type by following these steps. The tool will pick up right where you left things off last time.
- There will be one sub-folder per image
- There will be one annotation file per landmark
If you have following images:
IMAGE_DIR/
- 1.png
- 2.png
And you have already annotated the landmarks "eye_left" and "eye_right", then your annotations folder will contain:
annotations/
- 1.png /
- eye_left.json
- eye_right.json
- 2.png /
- eye_left.json
- eye_right.json
The content of the .json
file will look like this:
# if the landmark was visible and annotated
{
"coordinates": {"x": 450, "y": 496},
"status": "ok"
}
# if the landmark was marked as occluded/missing
{
"status": "occluded/missing"
}
If you press skip, no .json file will be created for this image.
python postprocessing_draw_landmarks.py
Please see the script for further information.
python postprocessing_merge_annotations.py
Please see the script for further information.
CTRL+C
to stop the annotation server- Change
config.py
python start.py
- Navigate to http://localhost:5000
Important: you always need to restart the server, so that it picks up on the changes.
The server will only pick up on these changes after a restart!
CTRL+C
to stop the annotation serverpython start.py
- Navigate to http://localhost:5000
Simply press the "back" button until you find the image and try again.
Delete the corresponding annotation .json
file and restart the server.
No.
No, but should not be too hard to add this to postprocessing_merge_annotations.py
.
No, they would overwrite each other's landmarks.
Yes.
No.
No.