Sub topic 8
Choosing and configuring an annotation tool
This chapter assumes you can read and write basic Python, know what a COCO or YOLO file contains, and have a written class taxonomy and labelling guideline. An annotation tool is where those documents become pixels and coordinates. A poor choice or a careless setup produces labels that look fine on screen but fail when you load them into a training pipeline.
What a tool has to do
An annotation tool is software that shows an image, lets a person draw labels on it, and saves those labels in a file format. Most projects need the same core features, whatever tool they pick:
- Draw the shapes your task needs: boxes, polygons, masks, or image-level tags.
- Enforce a fixed list of classes so annotators cannot invent spellings such as
Car,carandcars. - Export to a format your training code reads.
- Track who labelled what, and support a review step.
- Handle your image count and file location without being slow.
Everything else, such as keyboard shortcuts, dashboards and model integration, is useful but secondary.
The decision, step by step
Work through these questions in order. Each one removes options.
- Which shapes do you need? A tool that only draws boxes cannot do instance segmentation. Check polygon support and, if you need it, brush or mask tools.
- How many people will label? One person can use a local desktop tool. Several people need shared projects, user accounts and a way to assign and review work.
- Where may the images live? If data cannot leave your network, you need a self-hosted or desktop tool. Hosted services require uploading images or granting access to your storage.
- Which export formats are required? Prefer a tool that writes COCO or YOLO directly. Every conversion step is a chance for a coordinate bug.
- Do you want model assistance? Some tools can load predictions as pre-labels or run a model while you label. The next chapters of the plan cover this in more detail.
- What does it cost to maintain? A self-hosted server needs updates, backups and someone responsible for it.
The diagram shows the same logic as a flow.
Categories of tools
The names below are examples, not endorsements. Features change between releases, so check the current documentation before you commit.
| Category | Examples | Strengths | Weaknesses |
|---|---|---|---|
| Desktop, single user | LabelImg, labelme | Simple install, no server, data stays local | No built-in review workflow, limited collaboration |
| Self-hosted web app | CVAT, Label Studio | Multi-user, review stages, many export formats | You run and secure the server |
| Hosted service | Commercial platforms | No setup, scaling, managed workforce options | Cost, data upload, vendor lock-in |
Desktop tools often save one file per image. LabelImg writes Pascal VOC XML or YOLO text files, and labelme writes one JSON file per image. You then merge those files into a dataset. Server tools store everything in a project and export a single file, such as a COCO JSON.
Configuring a tool before anyone labels
Most labelling problems that appear later were decided at setup. Do these steps before the first real image is labelled.
Fix the class list and its order
Enter the classes exactly as the taxonomy defines them. Class order matters for YOLO, because the label files store a class index (0, 1, 2) rather than a name. If you add a class in the middle of the list later, every existing index after it shifts and old labels point to the wrong class.
Add new classes at the end, and never reorder a list that has labelled data. Keep a classes.txt or equivalent file in version control next to the data.
Choose the right shape per class
Some tools let you restrict a class to one shape type. Use that. If person should be a box and road should be a polygon, set it up so annotators cannot draw the wrong one.
Put the guideline inside the tool
Many tools allow a text description per class or per project. Paste in the short rule and a link to the full guideline with example images. Annotators who must leave the tool to check a rule will often guess instead.
Set up attributes only if you will use them
Attributes are extra fields on a label, such as occluded, truncated or difficult. They are cheap to add and expensive to collect inconsistently. Add an attribute only if your guideline defines it precisely and your training or evaluation code will read it.
Turn on sensible defaults
- Enable snapping or zoom-aware drawing so boxes are tight at high zoom.
- Set the default label so the most common class needs no extra click.
- Disable features that tempt annotators to take shortcuts, such as auto-copying a box to the next frame when objects move.
Check the export before you scale up
Label ten images, export them, and inspect the result. Do not label a thousand images and then discover a problem. This pilot is the single most useful step in tool setup.
The script below loads a COCO export, checks the structure, and flags the box problems described earlier in the plan. It runs as written if you save it as check_export.py and point it at a COCO file.
import json
import sys
def check_box(bbox, img_w, img_h):
x, y, w, h = bbox
problems = []
if w <= 0 or h <= 0:
problems.append("non-positive size")
if x < 0 or y < 0 or x + w > img_w or y + h > img_h:
problems.append("box extends outside image")
return problems
def check_export(path):
with open(path, encoding="utf-8") as f:
data = json.load(f)
images = {img["id"]: img for img in data["images"]}
categories = {c["id"]: c["name"] for c in data["categories"]}
report = []
for ann in data["annotations"]:
img = images.get(ann["image_id"])
if img is None:
report.append((ann["id"], "image_id not in images"))
continue
if ann["category_id"] not in categories:
report.append((ann["id"], "unknown category_id"))
for problem in check_box(ann["bbox"], img["width"], img["height"]):
report.append((ann["id"], problem))
print(f"{len(images)} images, {len(data['annotations'])} annotations")
print("categories:", sorted(categories.values()))
for ann_id, problem in report:
print(f"annotation {ann_id}: {problem}")
return report
if __name__ == "__main__":
check_export(sys.argv[1])Run it as python check_export.py export.json. A clean pilot prints the counts and the class names and no problem lines.
Beyond the script, open three or four exported images with their labels drawn on top, using a separate viewer or a few lines of drawing code. A script cannot tell you that every box is shifted by a few pixels, but your eyes can.
Common export problems
| Symptom | Likely cause | What to check |
|---|---|---|
| Boxes shifted or scaled | Image was resized in the tool but not in the export, or the reverse | Compare `width` and `height` in the file with the real image size |
| Wrong class names in training | Class order changed between export and training config | Compare the export's category list with your `classes.txt` |
| Boxes slightly outside the image | Annotator dragged past the border, or rounding on export | Run the box check, then clip or fix |
| Missing labels for some images | Images with no objects were skipped on export | Decide whether empty images should appear, and check the export option |
| Polygons with fewer than three points | Accidental clicks | Filter or fix in review |
| Duplicate annotations | Re-import of the same file, or a copy action | Count annotations per image and compare IoU between same-class boxes |
Empty images deserve special thought. An image with no objects is a valid training example because it teaches the model what background looks like. Some YOLO exports omit the label file for such images, and some training code treats a missing file as an empty label while other code treats it as an error. Test this with your training framework.
Version your configuration
Treat the tool setup as part of the dataset. Record these items in the repository next to the labels:
- The class list in its final order.
- The tool name and version used to export.
- The export format and any options chosen.
- The guideline version the annotators followed.
When a model underperforms six months from now, you will need this record to tell whether the labels changed or the model did.
Edge cases
- Large images. Very large images (satellite or medical scans) can make web tools slow. Check whether the tool supports tiling or whether you should tile the images before upload. Tiling changes coordinates, so record the offset of each tile.
- Multiple frames from video. Tools with interpolation can fill in boxes between keyframes. Review the interpolated frames, because linear motion rarely matches real motion.
- Mixed shapes in one project. If one export contains boxes for some classes and polygons for others, check that your converter handles both. Some YOLO converters keep only boxes or only polygons.
- Pixel coordinates versus normalised. Know which one the tool shows on screen and which one it exports. Confusing them produces values that look plausible but are wrong, such as a box width of 0.15 treated as pixels.
- Image orientation. A photo with an EXIF rotation tag can display rotated in one program and unrotated in another. If the tool and the training loader disagree, the boxes land in the wrong place. Test with a rotated phone photo.
Exercise
You export 50 labelled images from a server tool as YOLO text files and start training. Detections come out with the wrong class names, although the boxes look right. The team had added a new class named bicycle near the top of the class list two weeks into labelling. What is the most likely cause, and how should the list have been handled?
Show answer
YOLO files store class indices, not names. Inserting bicycle near the top shifted the index of every class after it, so older labels now point to different classes than the training config expects. New classes should be added at the end of the list, the order should be kept in version control, and any unavoidable reordering needs a migration step that remaps the old indices.
Exercise
List three things you would check in a pilot export of ten images before labelling the full dataset.
Show answer
Any three of the following: the image width and height in the file match the real images; class names and order match the taxonomy; boxes pass a check for positive size and staying inside the image; polygons have at least three points; images with no objects are handled the way your training code expects; a few images overlaid with their labels look correct to the eye.