mindspore.ops.IOU
- class mindspore.ops.IOU(mode='iou')[source]
Calculates intersection over union for boxes.
Computes the intersection over union (IOU) or the intersection over foreground (IOF) based on the ground-truth and predicted regions.
Refer to
mindspore.ops.iou()
for more details.- Parameters
mode (string) – The mode is used to specify the calculation method, now supporting
'iou'
(intersection over union) or'iof'
(intersection over foreground) mode. Default:'iou'
.
- Inputs:
anchor_boxes (Tensor) - Anchor boxes, tensor of shape
. "N" indicates the number of anchor boxes, and the value "4" refers to "x0", "y0", "x1", and "y1". Data type must be float16 or float32.gt_boxes (Tensor) - Ground truth boxes, tensor of shape
. "M" indicates the number of ground truth boxes, and the value "4" refers to "x0", "y0", "x1", and "y1". Data type must be float16 or float32.
- Outputs:
Tensor, the 'iou' values, tensor of shape
, with the same data type as anchor_boxes.- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> 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)