mindspore.ops.check_valid
- mindspore.ops.check_valid(bboxes, img_metas)[source]
Checks bounding box.
Checks whether the bounding box cross data and data border are valid.
Warning
Boundary(heights * ratio, widths * ratio) specified by bboxes is required to be valid.
- Parameters
bboxes (Tensor) – Bounding boxes tensor with shape \((N, 4)\). \(N\) indicates the number of bounding boxes, the value 4 indicates x0, x1, y0, and y1. Data type must be float16 or float32.
img_metas (Tensor) – Raw image size information with the format of (height, width, ratio), specifying the valid boundary (height * ratio, width * ratio). Data type must be float16 or float32.
- Returns
Tensor, with shape of \((N,)\) 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
>>> bboxes = Tensor(np.linspace(0, 6, 12).reshape(3, 4), mindspore.float32) >>> img_metas = Tensor(np.array([2, 1, 3]), mindspore.float32) >>> output = ops.check_valid(bboxes, img_metas) >>> print(output) [ True False False]