Skip to content

Commit 9cd771d

Browse files
Merge pull request #1114 from misrasaurabh1/codeflash/optimize-extract_x_coordinate_of_detections_center-m7dse7wf
⚡️ Speed up function `extract_x_coordinate_of_detections_center` by 35%
2 parents 94fec52 + 52b3602 commit 9cd771d

File tree

1 file changed

+2
-2
lines changed
  • inference/core/workflows/core_steps/common/query_language/operations/detections

1 file changed

+2
-2
lines changed

inference/core/workflows/core_steps/common/query_language/operations/detections/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@ def select_detections(
172172

173173

174174
def extract_x_coordinate_of_detections_center(detections: sv.Detections) -> np.ndarray:
175-
return detections.xyxy[:, 0] + (detections.xyxy[:, 2] - detections.xyxy[:, 0]) / 2
175+
return (detections.xyxy[:, 0] + detections.xyxy[:, 2]) * 0.5
176176

177177

178178
def extract_y_coordinate_of_detections_center(detections: sv.Detections) -> np.ndarray:
179-
return detections.xyxy[:, 1] + (detections.xyxy[:, 3] - detections.xyxy[:, 1]) / 2
179+
return (detections.xyxy[:, 1] + detections.xyxy[:, 3]) * 0.5
180180

181181

182182
SORT_PROPERTIES_EXTRACT = {

0 commit comments

Comments
 (0)