Commit 3a4fdf64 authored by Yuxin Wu's avatar Yuxin Wu

[FasterRCNN] fix clip_boxes for nd boxes

parent 00ebd097
...@@ -107,14 +107,16 @@ def segmentation_to_mask(polys, height, width): ...@@ -107,14 +107,16 @@ def segmentation_to_mask(polys, height, width):
def clip_boxes(boxes, shape): def clip_boxes(boxes, shape):
""" """
Args: Args:
boxes: nx4, float boxes: (...)x4, float
shape: h, w shape: h, w
""" """
orig_shape = boxes.shape
boxes = boxes.reshape([-1, 4])
h, w = shape h, w = shape
boxes[:, [0, 1]] = np.maximum(boxes[:, [0, 1]], 0) boxes[:, [0, 1]] = np.maximum(boxes[:, [0, 1]], 0)
boxes[:, 2] = np.minimum(boxes[:, 2], w) boxes[:, 2] = np.minimum(boxes[:, 2], w)
boxes[:, 3] = np.minimum(boxes[:, 3], h) boxes[:, 3] = np.minimum(boxes[:, 3], h)
return boxes return boxes.reshape(orig_shape)
def print_config(): def print_config():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment