mindspore.ops.CheckValid

class mindspore.ops.CheckValid(*args, **kwargs)[source]

Checks bounding box.

Checks whether the bounding box cross data and data border are valid.

Inputs:
  • bboxes (Tensor) - Bounding boxes tensor with shape (N, 4). Data type must be float16 or float32.

  • img_metas (Tensor) - Raw image size information with the format of (height, width, ratio). Data type must be float16 or float32.

Outputs:

Tensor, with shape of (N,) and dtype of bool.

Raises
  • TypeError – If bboxes or img_metas is not a Tensor.

  • TypeError – If dtype of bboxes or img_metas is neither float16 nor float32.

Supported Platforms:

Ascend GPU

Examples

>>> import mindspore
>>> import mindspore.nn as nn
>>> import numpy as np
>>> from mindspore import Tensor
>>> from mindspore.ops import operations as ops
>>> class Net(nn.Cell):
...     def __init__(self):
...         super(Net, self).__init__()
...         self.check_valid = ops.CheckValid()
...     def construct(self, x, y):
...         valid_result = self.check_valid(x, y)
...         return valid_result
...
>>> bboxes = Tensor(np.linspace(0, 6, 12).reshape(3, 4), mindspore.float32)
>>> img_metas = Tensor(np.array([2, 1, 3]), mindspore.float32)
>>> net = Net()
>>> output = net(bboxes, img_metas)
>>> print(output)
[ True False False]