mindspore.ops.IOU

查看源文件
class mindspore.ops.IOU(mode='iou')[源代码]

计算矩形的IOU,即真实区域和预测区域的交并比。

根据真实区域和预测区域计算IOU(intersection over union)或IOF(intersection over foreground)。

更多参考详见 mindspore.ops.iou()

参数:
  • mode (string) - 指定计算方法,现支持 'iou' (intersection over union)或 'iof' (intersection over foreground)模式。默认值: 'iou'

输入:
  • anchor_boxes (Tensor) - 预测区域,shape为 \((N, 4)\) 的Tensor。”N”表示预测区域的数量,”4”表示”x0”、”y0”、”x1”和”y1”。数据类型为float16或float32。

  • gt_boxes (Tensor) - 真实区域,shape为 \((M, 4)\) 的Tensor。”M”表示地面真实区域的数量,”4”表示”x0”、”y0”、”x1”和”y1”。数据类型为float16或float32。

输出:

IOU值的Tensor,shape为 \((M, N)\) 的Tensor,数据类型与 anchor_boxes 的相同。

支持平台:

Ascend GPU CPU

样例:

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> iou = ops.IOU(mode='iou')
>>> anchor_boxes = Tensor(np.random.randint(1.0, 5.0, [3, 4]), mindspore.float16)
>>> gt_boxes = Tensor(np.random.randint(1.0, 5.0, [3, 4]), mindspore.float16)
>>> output = iou(anchor_boxes, gt_boxes)
>>> print(output.shape)
(3, 3)