MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / clip_boxes

Function clip_boxes

examples/FasterRCNN/common.py:112–124  ·  view source on GitHub ↗

Args: boxes: (...)x4, float shape: h, w

(boxes, shape)

Source from the content-addressed store, hash-verified

110
111
112def clip_boxes(boxes, shape):
113 """
114 Args:
115 boxes: (...)x4, float
116 shape: h, w
117 """
118 orig_shape = boxes.shape
119 boxes = boxes.reshape([-1, 4])
120 h, w = shape
121 boxes[:, [0, 1]] = np.maximum(boxes[:, [0, 1]], 0)
122 boxes[:, 2] = np.minimum(boxes[:, 2], w)
123 boxes[:, 3] = np.minimum(boxes[:, 3], h)
124 return boxes.reshape(orig_shape)
125
126
127def filter_boxes_inside_shape(boxes, shape):

Callers 1

predict_imageFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected