Shortcuts

clip_boxes_to_image

torchvision.ops.clip_boxes_to_image(boxes: Tensor, size: Tuple[int, int]) Tensor[source]

裁剪框,使其位于大小为 size 的图像内。

注意

为了裁剪一个BoundingBoxes对象,考虑使用转换ClampBoundingBoxes()代替。

Parameters:
  • boxes (Tensor[N, 4]) – 以(x1, y1, x2, y2)格式表示的框 其中0 <= x1 < x20 <= y1 < y2

  • size (Tuple[height, width]) – 图像的尺寸

Returns:

裁剪的盒子

Return type:

张量[N, 4]