def convert_coco_bbox(
    coords: Sequence[float],
    img_size: Sequence[int],
    target: BBoxType,
) -> list[float]:
    """Convert the COCO bounding box coordinates to other formats."""
    if target == "albumentations":
        return [
            coords[0] / img_size[0],
            coords[1] / img_size[1],
            (coords[0] + coords[2]) / img_size[0],
            (coords[1] + coords[3]) / img_size[1],
        ]
    if target == "coco":
        return list(coords)
    if target == "voc":
        return [coords[0], coords[1], coords[0] + coords[2], coords[1] + coords[3]]
    if target == "yolo":
        return [
            (coords[0] + coords[2] / 2) / img_size[0],
            (coords[1] + coords[3] / 2) / img_size[1],
            coords[2] / img_size[0],
            coords[3] / img_size[1],
        ]
    raise ValueError(f"Unsupported target format: {target}")
Convert the COCO bounding box coordinates to other formats.
src/datachain/model/utils.py