mindspore.ops.CheckValid
- class mindspore.ops.CheckValid[source]
Checks bounding box.
Checks whether the bounding boxes specified by bboxes is valid. Returns True if the box is within borders specified by img_metas, False if not.
- Inputs:
bboxes (Tensor) - Bounding boxes tensor with shape
. indicates the number of bounding boxes, the value "4" indicates "x0", "y0", "x1", and "y1". Data type must be float16 or float32.img_metas (Tensor) - Raw image size information with the format of
, specifying the valid boundary . Data type must be float16 or float32.
- Outputs:
Tensor, with shape of
and dtype of bool, specifying whether the bounding boxes is in the image. "True" indicates valid, while "False" indicates invalid.
- Raises
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> import mindspore.nn as nn >>> import numpy as np >>> from mindspore import Tensor, 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]