Bounding-box labeling · YOLO, COCO and Pascal VOC

Image Labeling for YOLO and COCO

Draw boxes on your images, give each a class, and export YOLO text files, a COCO JSON file and Pascal VOC XML in one ZIP. Existing labels in any of the three formats can be imported and edited.

Images

Drop images here or click to choose

PNG, JPG, WEBP, GIF or BMP, up to 25 MB each, 200 images.

Classes

Press 1 to 9 to pick a class

  • 0

Import labels

Choose YOLO .txt files (with classes.txt or data.yaml), a COCO .json file, or VOC .xml files together. Images must already be added; labels replace the boxes of the images they match by file name.

Drop label files here or click to choose

Up to 25 MB per file

Export

Canvas

Add images to start labeling

Your image appears here.

Image Labeling for YOLO and COCO

Operator: Abdulla Al Fahad. How tools are built and checked

A box drawn from (64, 48) to (192, 144) on a 640 x 480 image is the same object in three files. YOLO stores it as '0 0.200000 0.200000 0.200000 0.200000', COCO as bbox [64, 48, 128, 96] with area 12288 and category 1, and Pascal VOC as xmin 65, ymin 49, xmax 192, ymax 144, because VOC counts pixels from 1. This page draws the box once and writes all three, with class numbering kept consistent, and reads any of the three back in.

Key features

  • Draw, select, move and resize boxes on a canvas, or edit a selected box's class, X, Y, width and height in number fields
  • Keys 1 to 9 pick a class, A and D move between images, arrows nudge a box by 1 px (10 with Shift), Delete removes it and Ctrl or Cmd+Z undoes
  • Import YOLO .txt with classes.txt, a .names file or data.yaml, COCO JSON or VOC XML, matched to images by file name
  • Export YOLO, COCO and VOC in one ZIP, with or without the images

Coordinates, class numbering and what each format stores

Up to 200 images of 25 MB each (PNG, JPG, WEBP, GIF first frame or BMP), 80 classes and 2,000 boxes per image. Box coordinates are in the pixels of the image as the browser shows it, with EXIF orientation applied; if your trainer ignores EXIF rotation, re-save rotated photos first.

YOLO: labels/<name>.txt with 'class cx cy w h' normalised to 0 to 1 at six decimals and class numbers from 0, plus classes.txt and a data.yaml with path, train, val, nc and names. COCO: coco/annotations.json with images, annotations (bbox [x, y, w, h], area, iscrowd 0) and categories numbered from 1. VOC: voc/Annotations/<name>.xml with the size, one object per box and integer pixel corners counted from 1 and inclusive, as in the original VOC devkit (a box starting at pixel 64 is written xmin 65), so xmin and ymin are the rounded-down start plus 1 and xmax and ymax the rounded-up end. YOLO and COCO count from 0.

Duplicate file names are made unique (photo.jpg, photo-2.jpg) so labels cannot overwrite each other. Boxes are clipped to the image on export, and a box thinner than 1 px after clipping is dropped. Class names are cleaned to one line of at most 40 characters, and names in XML and YAML are escaped.

How it works

Boxes are kept in image pixels, so one set converts into every format without rounding drift. A class number is its position in the class list, which is why a class cannot be removed while boxes use it, and why removing an unused class moves every class above it down by one.

Importing reads class names first, from classes.txt or the names block of data.yaml, so YOLO numbers mean what they meant in the dataset they came from; COCO and VOC class names are added to the list when new. Files are matched to images by name: YOLO and VOC files by stem (cat.txt to cat.jpg), COCO by each image's file_name. The boxes of a matched image are replaced, and unmatched files are listed.

Common use cases

  • Boxing 150 shelf photos with three classes (bottle, can, box): keys 1 to 3 switch class between boxes, and YOLO and COCO come out of the same session, so one set feeds both a training script and a COCO-format evaluation tool.
  • Fixing a downloaded dataset: import its YOLO .txt files and data.yaml onto the images, delete the wrong boxes, nudge boxes that are a few pixels off with the arrow keys, and export the corrected set as VOC for another tool.

How to use this tool

  1. Add the images to label.
  2. Name the classes in the Classes card; press 1 to 9 to choose one.
  3. Drag on the picture to draw boxes. Click one to select it, then drag to move it, drag a corner to resize it, or type exact numbers.
  4. Move through the set with A and D, or Page Up and Page Down.
  5. Choose the formats, decide whether to include the images, and download the ZIP.

Example

One box on a 640 x 480 image, class 0 (cat), x 64, y 48, width 128, height 96

YOLO labels/cat.txt
COCO annotations.json
VOC cat.xml

What is written

0 0.200000 0.200000 0.200000 0.200000
bbox [64, 48, 128, 96], area 12288, category_id 1
xmin 65, ymin 49, xmax 192, ymax 144

Tips for best results

  • Type exact sizes for small boxes. The number fields work in image pixels, so a 12 x 12 px object on a 4000 px photo is easier to size by typing than by dragging a 3 px handle.
  • Put the classes in the order your training config expects before you draw, because export numbers classes by position.
  • When importing YOLO files, select classes.txt or data.yaml in the same choice as the .txt files; the class list is read first, so the numbers keep their meaning.

Common pitfalls

Very small boxes can disappear on export: a box under 2 px cannot be drawn, and one under 1 px after clipping to the image is dropped.

Importing replaces the boxes of every matched image, including images you labeled by hand, so export first if you are not sure.

A VOC file from a tool that counts pixels from 0 imports one pixel right and down of where it was drawn, because this page reads VOC as 1-based. Nudge with the arrow keys or accept the one-pixel offset.

Common errors and how to fix them

No matching image for: 0001.txt
A YOLO or VOC file is matched by its name without the extension, ignoring case, so 0001.txt belongs to 0001.jpg. Add the image first, or rename the label file to match.
3 lines were skipped (segmentation polygons or invalid numbers)
This tool reads box lines of five numbers (a sixth, a confidence value, is tolerated). YOLO segmentation files list many points per line and cannot be imported as boxes.

YOLO, COCO and VOC compared

The three formats store the same rectangle in different coordinates, which is the usual cause of boxes that land in the wrong place after a conversion.

  • YOLO: centre and size, divided by the image width and height, class numbers from 0, one .txt file per image
  • COCO: top-left corner and size in pixels, category numbers from 1, one JSON file for all images
  • VOC: top-left and bottom-right pixel corners counted from 1 and inclusive, class by name, one XML file per image

Frequently asked questions

Are COCO category ids the same as YOLO class numbers?

They differ by one in this export. The class at position 0 is YOLO class 0 and COCO category 1, because COCO ids start at 1. Both come from the same list, so they stay in step.

Can I label polygons or keypoints?

No. Only axis-aligned rectangles are supported, and the segmentation lines of an imported YOLO file are skipped.

What if two images have the same file name?

Both are kept. On export their names are made unique, cat.jpg and cat.png becoming cat.jpg and cat-2.png, and the labels, VOC files and COCO file_name all use the new names so none overwrites another.