快捷方式

box_convert

torchvision.ops.box_convert(boxes: Tensor, in_fmt: str, out_fmt: str) Tensor[源代码]

torch.Tensor 框从给定的 in_fmt 转换为 out_fmt

注意

对于在不同格式之间转换 torch.TensorBoundingBoxes 对象,请考虑使用 convert_bounding_box_format() 代替。或者参阅相应的转换 ConvertBoundingBoxFormat()

支持的 in_fmtout_fmt 字符串为

'xyxy':框通过角表示,x1、y1 为左上角,x2、y2 为右下角。这是 torchvision 实用程序期望的格式。

'xywh':框通过角、宽度和高度表示,x1、y2 为左上角,w、h 为宽度和高度。

'cxcywh':框通过中心、宽度和高度表示,cx、cy 为框的中心,w、h 为宽度和高度。

参数:
  • boxes (Tensor[N, 4]) – 将被转换的框。

  • in_fmt (str) – 给定框的输入格式。支持的格式为 [‘xyxy’, ‘xywh’, ‘cxcywh’]。

  • out_fmt (str) – 给定框的输出格式。支持的格式为 [‘xyxy’, ‘xywh’, ‘cxcywh’]

返回值:

转换为指定格式的框。

返回类型:

Tensor[N, 4]

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取针对初学者和高级开发者的深入教程

查看教程

资源

查找开发资源并获得问题解答

查看资源