dgs.utils.validation.validate_bboxes¶
- dgs.utils.validation.validate_bboxes(bboxes: torchvision.tv_tensors.BoundingBoxes, length: int | None = None, dims: int | None = 2, box_format: torchvision.tv_tensors.BoundingBoxFormat | None = None) torchvision.tv_tensors.BoundingBoxes [source]¶
Given a torchvision tensor of bounding boxes, validate them and return them as a torchvision-tensor of bounding-boxes.
- Parameters:
bboxes – tv_tensor.BoundingBoxes object with an arbitrary shape, most likely
[B x 4]
.length – The number of items or batch-size the tensor should have. Default None does not validate the length.
dims – Number of dimensions bboxes should have. Use None to not force any number of dimensions. Defaults to two dimensions with the bounding box dimensions as
[B x 4]
.box_format – If present, validates whether the tv_tensors.BoundingBoxFormat matches the one of bboxes. Default None, and therefore no validation of the format.
- Returns:
Bounding boxes as tv_tensor.BoundingBoxes object with exactly dims dimensions.
- Raises:
TypeError – If the bboxes input is not a Tensor.
ValueError – If the bboxes have the wrong shape or the bboxes have the wrong format.