Shortcuts

box_convert

torchvision.ops.box_convert(boxes: torch.Tensor, in_fmt: str, out_fmt: str)torch.Tensor[source]

Converts boxes from given in_fmt to out_fmt. Supported in_fmt and out_fmt are:

‘xyxy’: boxes are represented via corners, x1, y1 being top left and x2, y2 being bottom right. This is the format that torchvision utilities expect.

‘xywh’ : boxes are represented via corner, width and height, x1, y2 being top left, w, h being width and height.

‘cxcywh’ : boxes are represented via centre, width and height, cx, cy being center of box, w, h being width and height.

Parameters
  • boxes (Tensor[N, 4]) – boxes which will be converted.

  • in_fmt (str) – Input format of given boxes. Supported formats are [‘xyxy’, ‘xywh’, ‘cxcywh’].

  • out_fmt (str) – Output format of given boxes. Supported formats are [‘xyxy’, ‘xywh’, ‘cxcywh’]

Returns

Boxes into converted format.

Return type

Tensor[N, 4]

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources