import torch


def xywh2xyxy(boxes):
    """ xywh -> xyxy
    (xmin,ymin,xmax,ymax) and (xcenter,ycenter,width,height)
    Args:
        boxes: torch.FloatTensor[N,4]
    """

    x1 = boxes[:, 0] - 0.5 * boxes[:, 2]
    y1 = boxes[:, 1] - 0.5 * boxes[:, 3]
    x2 = boxes[:, 0] + 0.5 * boxes[:, 2]
    y2 = boxes[:, 1] + 0.5 * boxes[:, 3]

    return torch.stack([x1, y1, x2, y2]).transpose(0, 1)