Skip to content

Commit 3b9e6ba

Browse files
Merge pull request #1217 from aseembits93/faster-rfdetr
⚡️ 11% (0.11x) speedup for `RFDETRObjectDetection.postprocess` in `inference/models/rfdetr/rfdetr.py`
2 parents b3a64cb + 4196de6 commit 3b9e6ba

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

inference/models/rfdetr/rfdetr.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,12 @@ def postprocess(
316316

317317
boxes_xyxy = boxes_input / scale
318318

319-
boxes_xyxy[:, 0] = np.clip(boxes_xyxy[:, 0], 0, orig_w)
320-
boxes_xyxy[:, 1] = np.clip(boxes_xyxy[:, 1], 0, orig_h)
321-
boxes_xyxy[:, 2] = np.clip(boxes_xyxy[:, 2], 0, orig_w)
322-
boxes_xyxy[:, 3] = np.clip(boxes_xyxy[:, 3], 0, orig_h)
319+
np.clip(
320+
boxes_xyxy,
321+
[0, 0, 0, 0],
322+
[orig_w, orig_h, orig_w, orig_h],
323+
out=boxes_xyxy,
324+
)
323325

324326
batch_predictions = np.column_stack(
325327
(

0 commit comments

Comments
 (0)