def xyxy2xywh(xyxy, inplace=False):
    """Convert bbox from (x1,y1,x2,y2) to (x1,y1,w,h).
    """
    if inplace:
        xywh = xyxy
    else:
        xywh = xyxy.clone()
    xywh[:, 2] = xyxy[:, 2] - xyxy[:, 0] + 1
    xywh[:, 3] = xyxy[:, 3] - xyxy[:, 1] + 1
    return xywh