def load_annotations(file):
    """Read annotations from file.

    Args:
        file (str): path to file.

    Returns:
        List[Dict[str, Any]] with bounding boxes
    """
    with open(file, "r") as in_file:
        content = xmltodict.parse(in_file.read())
    filename = content["annotation"]["filename"]
    width = int(content["annotation"]["size"]["width"])
    height = int(content["annotation"]["size"]["height"])
    objects = content["annotation"]["object"]
    objects = [objects] if isinstance(objects, dict) else objects
    annots = []
    for item in objects:
        annots.append(
            {
                "category": item["name"].lower().strip(),
                "x1": int(item["bndbox"]["xmin"]),
                "y1": int(item["bndbox"]["ymin"]),
                "x2": int(item["bndbox"]["xmax"]),
                "y2": int(item["bndbox"]["ymax"]),
            }
        )
    return filename, (width, height), annots
Read annotations from file.

    Args:
        file (str): path to file.

    Returns:
        List[Dict[str, Any]] with bounding boxes
    
examples/detection/to_coco.py