mindspore.ops.bounding_box_decode

mindspore.ops.bounding_box_decode(anchor_box, deltas, max_shape, means=(0.0, 0.0, 0.0, 0.0), stds=(1.0, 1.0, 1.0, 1.0), wh_ratio_clip=0.016)[source]

Decode the bounding box locations, calculate the offset, and convert the offset into a Bbox, which is used to mark the target in the subsequent images, etc.

Parameters
  • anchor_box (Tensor) – Anchor boxes. The shape of anchor_box must be \((n, 4)\).

  • deltas (Tensor) – Delta of boxes. Which has the same shape with anchor_box.

  • max_shape (tuple) – The max size limit for decoding box calculation.

  • means (tuple, optional) – The means of deltas calculation. Default: (0.0, 0.0, 0.0, 0.0) .

  • stds (tuple, optional) – The standard deviations of deltas calculation. Default: (1.0, 1.0, 1.0, 1.0) .

  • wh_ratio_clip (float, optional) – The limit of width and height ratio for decoding box calculation. Default: 0.016 .

Returns

Tensor, decoded boxes. It has the same data type and shape as anchor_box.

Raises
  • TypeError – If means, stds or max_shape is not a tuple.

  • TypeError – If wh_ratio_clip is not a float.

  • TypeError – If anchor_box or deltas is not a Tensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> from mindspore import Tensor, ops
>>> anchor_box = Tensor([[4, 1, 2, 1], [2, 2, 2, 3]], mindspore.float32)
>>> deltas = Tensor([[3, 1, 2, 2], [1, 2, 1, 4]], mindspore.float32)
>>> output = ops.bounding_box_decode(anchor_box, deltas, max_shape=(768, 1280), means=(0.0, 0.0, 0.0, 0.0),
...                                  stds=(1.0, 1.0, 1.0, 1.0), wh_ratio_clip=0.016)
>>> print(output)
[[ 4.1953125  0.         0.         5.1953125]
 [ 2.140625   0.         3.859375  60.59375  ]]