def load_coco_classes(coco):
    """ Loads the class to label mapping (and inverse) for COCO.
    """
    # load class names (name -> label)
    categories = coco.loadCats(coco.getCatIds())
    categories.sort(key=lambda x: x["id"])

    classes = {}
    coco_labels = {}
    coco_labels_inverse = {}
    for c in categories:
        coco_labels[len(classes)] = c["id"]
        coco_labels_inverse[c["id"]] = len(classes)
        classes[c["name"]] = len(classes)

    return classes, coco_labels, coco_labels_inverse