File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
inference/core/workflows/core_steps/common Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -361,10 +361,11 @@ def scale_sv_detections(
361361 return detections_copy
362362 detections_copy .xyxy = (detections_copy .xyxy * scale ).round ()
363363 if keypoints_key in detections_copy .data :
364- for i in range (len (detections_copy [keypoints_key ])):
365- detections_copy [keypoints_key ][i ] = (
366- detections_copy [keypoints_key ][i ].astype (np .float32 ) * scale
367- ).round ()
364+ detections_copy .data [keypoints_key ] = (
365+ (detections_copy .data [keypoints_key ].astype (np .float32 ) * scale )
366+ .round ()
367+ .astype (np .int32 )
368+ )
368369 detections_copy [IMAGE_DIMENSIONS_KEY ] = (
369370 detections_copy [IMAGE_DIMENSIONS_KEY ] * scale
370371 ).round ()
@@ -391,11 +392,11 @@ def scale_sv_detections(
391392 scaled_masks .append (scaled_detection_mask )
392393 detections_copy .mask = np .array (scaled_masks )
393394 if POLYGON_KEY_IN_SV_DETECTIONS in detections_copy .data :
394- scaled_polygons = []
395- for polygon in detections_copy [POLYGON_KEY_IN_SV_DETECTIONS ]:
396- scaled_polygon = ( polygon * scale ) .round (). astype ( np . int32 )
397- scaled_polygons . append ( scaled_polygon )
398- detections_copy [ POLYGON_KEY_IN_SV_DETECTIONS ] = np . array ( scaled_polygons )
395+ detections_copy . data [ POLYGON_KEY_IN_SV_DETECTIONS ] = (
396+ ( detections_copy . data [POLYGON_KEY_IN_SV_DETECTIONS ] * scale )
397+ .round ()
398+ . astype ( np . int32 )
399+ )
399400 if SCALING_RELATIVE_TO_PARENT_KEY in detections_copy .data :
400401 detections_copy [SCALING_RELATIVE_TO_PARENT_KEY ] = (
401402 detections_copy [SCALING_RELATIVE_TO_PARENT_KEY ] * scale
You can’t perform that action at this time.
0 commit comments