TExcelTAD
Home › Computer Vision: Images to Detection, Segmentation & Tracking › Box Formats: Pascal VOC, COCO and YOLO

Box Formats: Pascal VOC, COCO and YOLO

A bounding box is four numbers, and there are at least four popular ways to write them. Datasets come in one format, training code expects another, and a converter with an off-by-one or a swapped width and height produces a model that trains without errors and scores badly, with no message anywhere saying why. This lesson pins down the three formats you will meet most (Pascal VOC XML, COCO JSON and YOLO text files), writes converters from scratch, and tests them the only way that catches every bug: a round trip on data whose boxes are known exactly. The folder layouts around these files are in dataset layouts; this lesson goes into the coordinates.

One box, four ways to write it

(x1, y1) = (40, 20)(x2, y2)centre (80, 50) w = 80 (0, 0)image W = 200, H = 100 pixels; y grows downwards corners (this course)[x1, y1, x2, y2] = [40, 20, 120, 80] COCO JSON"bbox": [x, y, w, h] = [40, 20, 80, 60] YOLO txtclass cx/W cy/H w/W h/H: 0 0.4 0.5 0.4 0.6 Pascal VOC XMLxmin 41 ymin 21 xmax 120 ymax 80 (1-based)

Every format agrees on the axes: the origin is the top-left corner of the image, xx grows to the right (columns) and yy grows down (rows). They disagree on what the four numbers are:

Format Numbers Units Where it lives
corners (this course, torchvision, most NMS code) x1, y1, x2, y2 pixels, x2, y2 exclusive in memory
COCO x, y, w, h: top-left corner and size pixels (floats allowed) one JSON file for a whole split
YOLO (Ultralytics, Darknet) class cx cy w h: centre and size fractions of the image width and height, 0 to 1 one .txt file per image, one line per object
Pascal VOC xmin, ymin, xmax, ymax pixels, 1-based and inclusive in the original devkit one XML file per image

With the image width WW and height HH, the conversions from corners are:

COCO:x=x1,y=y1,w=x2−x1,h=y2−y1YOLO:cx=x1+x22W,cy=y1+y22H,wn=x2−x1W,hn=y2−y1Hback:x1=(cx−wn/2) W,x2=(cx+wn/2) W(same for y with H)\begin{aligned} \text{COCO:}\quad & x = x_1,\quad y = y_1,\quad w = x_2 - x_1,\quad h = y_2 - y_1 \\ \text{YOLO:}\quad & c_x = \frac{x_1 + x_2}{2W},\quad c_y = \frac{y_1 + y_2}{2H},\quad w_n = \frac{x_2 - x_1}{W},\quad h_n = \frac{y_2 - y_1}{H} \\ \text{back:}\quad & x_1 = (c_x - w_n / 2)\, W,\quad x_2 = (c_x + w_n / 2)\, W \quad \text{(same for } y \text{ with } H) \end{aligned}

Exclusive or inclusive? This course writes x2 exclusive: a box covering pixel columns 40 to 119 has x1 = 40, x2 = 120 and width x2−x1=80x_2 - x_1 = 80, with no "+1". Think of the coordinates as lying on the pixel edges: pixel column 40 spans 40≤x<4140 \le x < 41. The VOC devkit (written in MATLAB, where arrays start at 1) stores the first and last pixel indices, counted from 1: the same box is xmin = 41, xmax = 120, and its width is xmax - xmin + 1 = 80. To read VOC into corners, subtract 1 from xmin and ymin and keep xmax and ymax. Many tools that write "VOC" files today ignore the 1-based rule and write 0-based values, so check a few boxes against their images before trusting any convention.

Converters and a round-trip test

The converters work on arrays of boxes at once. The test generates 200 of the course's synthetic scenes (make_scene: squares, circles and triangles with exact boxes), converts every box corners → COCO → corners, corners → YOLO → corners and corners → VOC → corners, and reports the largest error. Any off-by-one shows up as an error of exactly 1.

python · try it yourself
import numpy as np, cv2

CLASSES = ["square", "circle", "triangle"]

def make_scene(rng, size=64, max_objects=3):
    """Noisy grey background with 1..max_objects shapes that do not touch.
    Returns RGB uint8 image, boxes (n, 4) as [x1, y1, x2, y2] with x2, y2 exclusive,
    labels (n,) indices into CLASSES, masks (n, size, size) bool."""
    img = rng.normal(110, 12, (size, size, 3)).clip(0, 255).astype(np.uint8)
    n = int(rng.integers(1, max_objects + 1))
    boxes, labels, masks = [], [], []
    for _ in range(100):
        if len(boxes) == n:
            break
        s = int(rng.integers(12, 25)); x = int(rng.integers(0, size - s)); y = int(rng.integers(0, size - s))
        if any(x < b[2] + 2 and b[0] < x + s + 2 and y < b[3] + 2 and b[1] < y + s + 2 for b in boxes):
            continue
        c = int(rng.integers(0, 3)); m = np.zeros((size, size), np.uint8)
        if c == 0:
            cv2.rectangle(m, (x, y), (x + s - 1, y + s - 1), 1, -1)
        elif c == 1:
            cv2.circle(m, (x + s // 2, y + s // 2), s // 2, 1, -1)
        else:
            cv2.fillPoly(m, [np.array([[x + s // 2, y], [x, y + s - 1], [x + s - 1, y + s - 1]], np.int32)], 1)
        img[m > 0] = rng.integers(0, 256, 3)
        ys, xs = np.nonzero(m)
        boxes.append([int(xs.min()), int(ys.min()), int(xs.max()) + 1, int(ys.max()) + 1])
        labels.append(c); masks.append(m > 0)
    return img, np.array(boxes).reshape(-1, 4), np.array(labels), np.array(masks)

def xyxy_to_coco(b):
    b = np.asarray(b, float)
    return np.stack([b[:, 0], b[:, 1], b[:, 2] - b[:, 0], b[:, 3] - b[:, 1]], 1)

def coco_to_xyxy(b):
    b = np.asarray(b, float)
    return np.stack([b[:, 0], b[:, 1], b[:, 0] + b[:, 2], b[:, 1] + b[:, 3]], 1)

def xyxy_to_yolo(b, W, H):
    b = np.asarray(b, float)
    return np.stack([(b[:, 0] + b[:, 2]) / (2 * W), (b[:, 1] + b[:, 3]) / (2 * H),
                     (b[:, 2] - b[:, 0]) / W, (b[:, 3] - b[:, 1]) / H], 1)

def yolo_to_xyxy(b, W, H):
    b = np.asarray(b, float)
    return np.stack([(b[:, 0] - b[:, 2] / 2) * W, (b[:, 1] - b[:, 3] / 2) * H,
                     (b[:, 0] + b[:, 2] / 2) * W, (b[:, 1] + b[:, 3] / 2) * H], 1)

def xyxy_to_voc(b):                     # 1-based, inclusive pixel indices
    b = np.asarray(b, int)
    return np.stack([b[:, 0] + 1, b[:, 1] + 1, b[:, 2], b[:, 3]], 1)

def voc_to_xyxy(b):
    b = np.asarray(b, int)
    return np.stack([b[:, 0] - 1, b[:, 1] - 1, b[:, 2], b[:, 3]], 1)

rng = np.random.default_rng(0)
boxes = np.concatenate([make_scene(rng)[1] for _ in range(200)])
print("boxes:", len(boxes), "| first:", boxes[0].tolist())
print("COCO:", xyxy_to_coco(boxes[:1]).astype(int).tolist()[0],
      "| YOLO:", xyxy_to_yolo(boxes[:1], 64, 64).round(6).tolist()[0],
      "| VOC:", xyxy_to_voc(boxes[:1]).tolist()[0])
err = lambda a: float(np.abs(a - boxes).max())
print("max error corners -> COCO -> corners:", err(coco_to_xyxy(xyxy_to_coco(boxes))))
print("max error corners -> YOLO -> corners:", err(yolo_to_xyxy(xyxy_to_yolo(boxes, 64, 64), 64, 64)))
print("max error corners -> VOC  -> corners:", err(voc_to_xyxy(xyxy_to_voc(boxes))))
shifted = xyxy_to_voc(boxes) - 1                 # bug: a reader that subtracts 1 from all four numbers
w = (np.minimum(shifted[:, 2], boxes[:, 2]) - np.maximum(shifted[:, 0], boxes[:, 0])).clip(0)
h = (np.minimum(shifted[:, 3], boxes[:, 3]) - np.maximum(shifted[:, 1], boxes[:, 1])).clip(0)
area = (boxes[:, 2] - boxes[:, 0]) * (boxes[:, 3] - boxes[:, 1])
iou = w * h / (2 * area - w * h)                  # both boxes have the same size
print(f"reader with -1 on all four: mean IoU with the truth {iou.mean():.3f}, worst {iou.min():.3f}")
boxes: 401 | first: [32, 9, 56, 33]
COCO: [32, 9, 24, 24] | YOLO: [0.6875, 0.328125, 0.375, 0.375] | VOC: [33, 10, 56, 33]
max error corners -> COCO -> corners: 0.0
max error corners -> YOLO -> corners: 0.0
max error corners -> VOC  -> corners: 0.0
reader with -1 on all four: mean IoU with the truth 0.796, worst 0.725

The 200 scenes hold 401 boxes; the first is the square [32, 9, 56, 33], which is [32, 9, 24, 24] in COCO, 0.6875 0.328125 0.375 0.375 in YOLO and 33 10 56 33 in VOC. The round trips are exact (a YOLO round trip through floating point can leave errors around 10−1410^{-14}; rounding to whole pixels on the way back, when the dataset has integer boxes, removes them). The last line shows what a common bug does: a reader that subtracts 1 from all four VOC numbers (instead of only from xmin and ymin) shifts every box one pixel left and up. Nothing crashes, and the boxes are still the right size, their mean IoU with the truth drops to 0.796 over the 401 boxes (worst 0.725, on the smallest objects). A detector trained and scored on such labels loses accuracy at the strict IoU thresholds of COCO's 0.5:0.95 average for no reason in the images.

COCO JSON: one file, three lists

A COCO annotation file is a single JSON object with three main lists. images gives every image an id, its file_name and its size. annotations has one entry per object with its own id, the image_id it belongs to, a category_id, the bbox as [x, y, w, h], the area (of the mask, if there is one) and iscrowd. categories maps category_id to a name. Two details catch people:

  • Category ids are not indices. The 80 COCO classes have ids from 1 to 90 with gaps (12, 26, 29, … are unused), and a custom dataset may have ids such as 3, 7 and 11. A model needs class indices 0 to K−1K - 1, so build a mapping and keep it with the model.
  • Images without objects appear in images and simply have no annotations. Code that builds the image list from the annotations silently drops them, and the model never sees a negative example.
python · try it yourself
import json
import numpy as np, cv2

CLASSES = ["square", "circle", "triangle"]

def make_scene(rng, size=64, max_objects=3):
    """Noisy grey background with 1..max_objects shapes that do not touch.
    Returns RGB uint8 image, boxes (n, 4) as [x1, y1, x2, y2] with x2, y2 exclusive,
    labels (n,) indices into CLASSES, masks (n, size, size) bool."""
    img = rng.normal(110, 12, (size, size, 3)).clip(0, 255).astype(np.uint8)
    n = int(rng.integers(1, max_objects + 1))
    boxes, labels, masks = [], [], []
    for _ in range(100):
        if len(boxes) == n:
            break
        s = int(rng.integers(12, 25)); x = int(rng.integers(0, size - s)); y = int(rng.integers(0, size - s))
        if any(x < b[2] + 2 and b[0] < x + s + 2 and y < b[3] + 2 and b[1] < y + s + 2 for b in boxes):
            continue
        c = int(rng.integers(0, 3)); m = np.zeros((size, size), np.uint8)
        if c == 0:
            cv2.rectangle(m, (x, y), (x + s - 1, y + s - 1), 1, -1)
        elif c == 1:
            cv2.circle(m, (x + s // 2, y + s // 2), s // 2, 1, -1)
        else:
            cv2.fillPoly(m, [np.array([[x + s // 2, y], [x, y + s - 1], [x + s - 1, y + s - 1]], np.int32)], 1)
        img[m > 0] = rng.integers(0, 256, 3)
        ys, xs = np.nonzero(m)
        boxes.append([int(xs.min()), int(ys.min()), int(xs.max()) + 1, int(ys.max()) + 1])
        labels.append(c); masks.append(m > 0)
    return img, np.array(boxes).reshape(-1, 4), np.array(labels), np.array(masks)

CAT_IDS = [3, 7, 11]                      # deliberately not 0, 1, 2: like COCO's ids with gaps
rng = np.random.default_rng(0)
scenes = [make_scene(rng) for _ in range(4)]
coco = {"images": [], "annotations": [],
        "categories": [{"id": CAT_IDS[k], "name": n} for k, n in enumerate(CLASSES)]}
for i, (img, boxes, labels, masks) in enumerate(scenes, start=1):
    coco["images"].append({"id": i, "file_name": f"scene_{i:04d}.png", "width": 64, "height": 64})
    for b, l, m in zip(boxes, labels, masks):
        x1, y1, x2, y2 = (int(v) for v in b)
        coco["annotations"].append({"id": len(coco["annotations"]) + 1, "image_id": i,
                                    "category_id": CAT_IDS[int(l)], "bbox": [x1, y1, x2 - x1, y2 - y1],
                                    "area": int(m.sum()), "iscrowd": 0})
coco["images"].append({"id": 5, "file_name": "scene_0005.png", "width": 64, "height": 64})  # no objects
text = json.dumps(coco)
print("JSON size:", len(text), "bytes |", len(coco["images"]), "images,", len(coco["annotations"]), "annotations")
print(json.dumps(coco["annotations"][0]))

# reading it back: category id -> contiguous index, boxes per image (including empty images)
data = json.loads(text)
cat_to_idx = {c["id"]: k for k, c in enumerate(sorted(data["categories"], key=lambda c: c["id"]))}
per_image = {im["id"]: [] for im in data["images"]}
for a in data["annotations"]:
    x, y, w, h = a["bbox"]
    per_image[a["image_id"]].append([x, y, x + w, y + h, cat_to_idx[a["category_id"]]])
print("category id -> index:", cat_to_idx)
for im_id, rows in per_image.items():
    print(f"image {im_id}: {len(rows)} objects {rows}")
same = all(np.array_equal(np.array(per_image[i + 1])[:, :4], s[1]) and
           np.array_equal(np.array(per_image[i + 1])[:, 4], s[2]) for i, s in enumerate(scenes))
print("boxes and classes identical to the generator:", same)
for a in coco["annotations"][:3]:
    print(f"annotation {a['id']} ({CLASSES[CAT_IDS.index(a['category_id'])]}): box area {a['bbox'][2] * a['bbox'][3]}, mask area {a['area']}")
JSON size: 1252 bytes | 5 images, 8 annotations
{"id": 1, "image_id": 1, "category_id": 3, "bbox": [32, 9, 24, 24], "area": 576, "iscrowd": 0}
category id -> index: {3: 0, 7: 1, 11: 2}
image 1: 1 objects [[32, 9, 56, 33, 0]]
image 2: 2 objects [[28, 1, 41, 14, 1], [49, 8, 63, 22, 0]]
image 3: 2 objects [[17, 32, 31, 46, 0], [34, 35, 48, 49, 0]]
image 4: 3 objects [[37, 18, 62, 43, 1], [1, 30, 18, 47, 0], [13, 2, 31, 20, 2]]
image 5: 0 objects []
boxes and classes identical to the generator: True
annotation 1 (square): box area 576, mask area 576
annotation 2 (circle): box area 169, mask area 113
annotation 3 (square): box area 196, mask area 196

The four scenes have 8 objects, and the fifth image has none: it is in images with an empty list, as it should be. The ids 3, 7 and 11 map back to indices 0, 1 and 2, and every box and class matches the generator. The area field is the area of the object (its mask), not of the box: for the squares the two agree (576 and 196), but the 13 x 13 circle of annotation 2 covers 113 pixels of its 169-pixel box. COCO evaluation uses it to split results into small (below 32232^2 pixels), medium and large objects, so filling it with the box area moves objects between those groups.

Pascal VOC XML: one file per image

A VOC annotation is an XML file per image with the image size and one object element per object, holding the class name, flags (truncated, difficult; see annotation tasks) and a bndbox. Python's standard xml.etree.ElementTree writes and parses it:

python · try it yourself
import xml.etree.ElementTree as ET

def write_voc(filename, W, H, objects):
    """objects: (name, [x1, y1, x2, y2]) in 0-based corners with x2, y2 exclusive."""
    root = ET.Element("annotation")
    ET.SubElement(root, "filename").text = filename
    size = ET.SubElement(root, "size")
    for tag, v in [("width", W), ("height", H), ("depth", 3)]:
        ET.SubElement(size, tag).text = str(v)
    for name, (x1, y1, x2, y2) in objects:
        obj = ET.SubElement(root, "object")
        ET.SubElement(obj, "name").text = name
        ET.SubElement(obj, "truncated").text = "1" if x1 == 0 or y1 == 0 or x2 == W or y2 == H else "0"
        ET.SubElement(obj, "difficult").text = "0"
        box = ET.SubElement(obj, "bndbox")
        for tag, v in [("xmin", x1 + 1), ("ymin", y1 + 1), ("xmax", x2), ("ymax", y2)]:   # 1-based inclusive
            ET.SubElement(box, tag).text = str(v)
    ET.indent(root)
    return ET.tostring(root, encoding="unicode")

def read_voc(text):
    root = ET.fromstring(text)
    out = []
    for obj in root.iter("object"):
        b = {t.tag: int(float(t.text)) for t in obj.find("bndbox")}
        out.append((obj.find("name").text, [b["xmin"] - 1, b["ymin"] - 1, b["xmax"], b["ymax"]],
                    int(obj.find("truncated").text)))
    return int(root.find("size/width").text), int(root.find("size/height").text), out

objects = [("square", [32, 9, 56, 33]), ("circle", [49, 8, 64, 22])]
xml_text = write_voc("scene_0001.png", 64, 64, objects)
print(xml_text)
print(read_voc(xml_text))
<annotation>
  <filename>scene_0001.png</filename>
  <size>
    <width>64</width>
    <height>64</height>
    <depth>3</depth>
  </size>
  <object>
    <name>square</name>
    <truncated>0</truncated>
    <difficult>0</difficult>
    <bndbox>
      <xmin>33</xmin>
      <ymin>10</ymin>
      <xmax>56</xmax>
      <ymax>33</ymax>
    </bndbox>
  </object>
  <object>
    <name>circle</name>
    <truncated>1</truncated>
    <difficult>0</difficult>
    <bndbox>
      <xmin>50</xmin>
      <ymin>9</ymin>
      <xmax>64</xmax>
      <ymax>22</ymax>
    </bndbox>
  </object>
</annotation>
(64, 64, [('square', [32, 9, 56, 33], 0), ('circle', [49, 8, 64, 22], 1)])

The second object touches the right border (x2 = 64 equals the width), so the writer marks it truncated. A reader that skips the - 1 would return [33, 10, 56, 33] for the square: a box one pixel smaller on the left and top. int(float(...)) accepts files that store coordinates as "41.0", which some exporters do.

YOLO text files: one line per object

Ultralytics and the Darknet family read a .txt file with the same name as each image (images/train/scene_0001.png ↔ labels/train/scene_0001.txt), one line class cx cy w h per object, the four numbers normalised by the image width and height, classes as 0-based indices into the names in the dataset YAML. An image without objects needs an empty label file (or none, which Ultralytics also treats as background; an empty file makes it explicit that someone looked).

python · try it yourself
import numpy as np

def to_yolo_lines(boxes, labels, W, H):
    lines = []
    for (x1, y1, x2, y2), c in zip(boxes, labels):
        x1, x2 = max(0, x1), min(W, x2); y1, y2 = max(0, y1), min(H, y2)     # clip to the image first
        lines.append(f"{c} {(x1 + x2) / 2 / W:.6f} {(y1 + y2) / 2 / H:.6f} {(x2 - x1) / W:.6f} {(y2 - y1) / H:.6f}")
    return "\n".join(lines)

def from_yolo_lines(text, W, H):
    out = []
    for line in text.splitlines():
        c, cx, cy, w, h = line.split()
        cx, cy, w, h = float(cx) * W, float(cy) * H, float(w) * W, float(h) * H
        out.append([int(c)] + [round(v) for v in (cx - w / 2, cy - h / 2, cx + w / 2, cy + h / 2)])
    return out

W, H = 96, 64                                    # NOT square: the wrong-side bug becomes visible
boxes = [[10, 8, 40, 30], [60, 20, 101, 50]]      # the second box sticks out on the right (x2 = 101 > 96)
files = {"img_0001.txt": to_yolo_lines(boxes, [0, 2], W, H),
         "img_0002.txt": to_yolo_lines([], [], W, H)}            # image with no objects
for name, text in files.items():
    print(f"{name}: {text!r}")
print("read back:", from_yolo_lines(files["img_0001.txt"], W, H))

def iou(a, b):
    w = max(0, min(a[2], b[2]) - max(a[0], b[0])); h = max(0, min(a[3], b[3]) - max(a[1], b[1]))
    return w * h / ((a[2] - a[0]) * (a[3] - a[1]) + (b[2] - b[0]) * (b[3] - b[1]) - w * h)

x1, y1, x2, y2 = boxes[0]                        # bug: x normalised by H and y by W
bad = [(x1 + x2) / 2 / H, (y1 + y2) / 2 / W, (x2 - x1) / H, (y2 - y1) / W]
cx, cy, w, h = bad[0] * W, bad[1] * H, bad[2] * W, bad[3] * H       # read correctly
back = [cx - w / 2, cy - h / 2, cx + w / 2, cy + h / 2]
print("wrong-side normalisation reads back as", [round(v, 1) for v in back], f"IoU with the truth {iou(back, boxes[0]):.3f}")
img_0001.txt: '0 0.260417 0.296875 0.312500 0.343750\n2 0.812500 0.546875 0.375000 0.468750'
img_0002.txt: ''
read back: [[0, 10, 8, 40, 30], [2, 60, 20, 96, 50]]
wrong-side normalisation reads back as [15.0, 5.3, 60.0, 20.0] IoU with the truth 0.294

Writing six decimals keeps sub-pixel precision for images up to about 100,000 pixels wide. The second box is clipped from x2 = 101 to 96 and reads back as [60, 20, 96, 50]; the empty image gets an empty string, written as an empty file. The clip happens before normalising: a box that sticks out of the image would otherwise get a normalised width above the image edge, which training code either rejects or silently clips in its own way. The last line is the wrong-side bug on a 96 x 64 image: the box [10, 8, 40, 30] comes back as [15.0, 5.3, 60.0, 20.0], IoU 0.294 with the truth, a miss at any threshold. On a square image it is invisible, which is why converters must be tested on non-square images.

Pitfalls

  • Off-by-one between conventions. Exclusive corners, inclusive 1-based VOC, and tools that write 0-based "VOC". Test with a round trip and look at a few boxes drawn on their images.
  • Normalising by the wrong side in YOLO files (xx by HH): invisible on square images, wrong on every other one.
  • Category ids used as class indices. With COCO's ids up to 90, a model with 80 outputs gets an index error, or worse, a model with 91 outputs trains with silent empty classes.
  • Dropping images without objects when converting: the model never learns "nothing here", and false positives rise.
  • Boxes outside the image from the annotation tool or from augmentation: clip them, and drop boxes whose clipped width or height is 0.
  • Boxes not transformed with the image. Resizing, cropping, letterboxing or flipping an image changes its boxes (resize and geometry, image preparation); YOLO's normalised boxes survive a resize but not a crop or padding.
  • (x, y, w, h) from OpenCV (cv2.boundingRect, detectMultiScale) looks like COCO and is, but cv2.rectangle draws with inclusive corners: draw (x, y) to (x + w - 1, y + h - 1) for an exact outline.

Practice

  1. A YOLO line 1 0.25 0.5 0.1 0.2 belongs to a 640 x 480 image. Write the box as corners and as COCO.
  2. A VOC file has xmin 1, ymin 1, xmax 50, ymax 20. What are the 0-based exclusive corners, and how wide is the box?
  3. A COCO file has categories with ids 1, 2, 3, 5 and 8. Write the mapping to class indices and its inverse, and say where each is used.
Answer
  1. Centre (0.25⋅640,0.5⋅480)=(160,240)(0.25 \cdot 640, 0.5 \cdot 480) = (160, 240), size (64,96)(64, 96). Corners [128, 192, 192, 288], COCO [128, 192, 64, 96], class index 1.
  2. [0, 0, 50, 20]; width 50−0=5050 - 0 = 50, which is also xmax - xmin + 1.
  3. {1: 0, 2: 1, 3: 2, 5: 3, 8: 4} turns the file's ids into the indices the model is trained on; the inverse {0: 1, 1: 2, 2: 3, 3: 5, 4: 8} turns predicted indices back into ids when you write predictions in COCO format for the official evaluation.

Test yourself

The same box is [40, 20, 120, 80] as corners in a 200 x 100 image. What is its YOLO line for class 0?

  1. 0 40 20 80 60
  2. 0 0.4 0.5 0.4 0.6
  3. 0 0.2 0.2 0.6 0.8
  4. 0 0.4 0.2 0.8 0.6

A Pascal VOC devkit file says xmin 11, xmax 30. In this course's 0-based corners with exclusive x2, the box spans…

  1. x1 = 11, x2 = 30
  2. x1 = 10, x2 = 30, width 20
  3. x1 = 10, x2 = 29, width 19
  4. x1 = 11, x2 = 31

Why should a box-format converter be tested on a non-square image?

  1. Square images are rare
  2. Because normalising x by the height and y by the width gives the right answer on square images and wrong boxes on all others
  3. YOLO does not support square images
  4. COCO needs non-square images

In a COCO file, what does the area of an annotation measure?

  1. Always the box area w times h
  2. The area of the object's segmentation mask (for box-only data often the box area), used to split results into small, medium and large objects
  3. The image area
  4. The number of annotations