Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

PR

Just a small problem.

I can fix it online!

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Problem description

Agree to Privacy Statement

mindspore.ops.check_valid

View Source On Gitee
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 (x0,x1) and two ordinate points (y0,y1) . img_metas provides information about the original image, including three parameters (height,width,ratio) , which specify the valid boundary of the image.

when the following conditions are met:

x0>=0

y0>=0

x1<=widthratio1

y1<=heightratio1

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.: x0<=x1 , y0<=y1 , and (height,width,ratio) are all positive.

Parameters
  • bboxes (Tensor) – Bounding boxes tensor with shape (N,4) . N indicates the number of bounding boxes, the value 4 indicates four coordinate points (x0,y0,x1,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 (heightratio1,widthratio1) . 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
  • 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 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]