mindspore.ops.check_valid
- mindspore.ops.check_valid(bboxes, img_metas)[source]
Checks whether the bounding box is in the image.
bboxes contain several sets of bounding boxes, each represented by two abscissa points
and two ordinate points . img_metas provides information about the original image, including three parameters , which specify the valid boundary of the image.when the following conditions are met:
the bounding box is considered to be within the image.
Warning
The bounding box specified by bboxes and the image information specified by img_metas need to be valid, i.e.:
, , and are all positive.- Parameters
bboxes (Tensor) – Bounding boxes tensor with shape
. indicates the number of bounding boxes, the value 4 indicates four coordinate points . 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.
- Returns
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 numpy as np >>> from mindspore import Tensor, ops >>> 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]