@@ -4511,17 +4511,46 @@ def NonMaxSuppressionV5_(boxes, scores, max_output_size: int, iou_threshold, sco
4511
4511
)
4512
4512
return selected_indices , selected_scores , valid_outputs
4513
4513
4514
- selected_indices , selected_scores , valid_outputs = \
4515
- tf . keras . layers . Lambda (
4516
- NonMaxSuppressionV5_ ,
4517
- arguments = { 'scores' : scores_reduce_max ,
4518
- 'max_output_size' : max_detections ,
4519
- 'iou_threshold' : nms_iou_threshold ,
4520
- 'score_threshold' : nms_score_threshold ,
4521
- 'soft_nms_sigma' : 0.0 ,
4522
- 'pad_to_max_output_size' : True }
4523
- )( boxes_concat )
4514
+ def NonMaxSuppressionV3_ ( boxes , scores , max_output_size : int , iou_threshold , score_threshold ):
4515
+ selected_indices = \
4516
+ tf . raw_ops . NonMaxSuppressionV3 (
4517
+ boxes = boxes ,
4518
+ scores = scores ,
4519
+ max_output_size = max_output_size ,
4520
+ iou_threshold = iou_threshold ,
4521
+ score_threshold = score_threshold
4522
+ )
4523
+ return selected_indices
4524
4524
4525
+ selected_indices = None
4526
+ selected_scores = None
4527
+ valid_outputs = None
4528
+ if not optimizing_for_openvino_and_myriad :
4529
+ selected_indices , selected_scores , valid_outputs = \
4530
+ tf .keras .layers .Lambda (
4531
+ NonMaxSuppressionV5_ ,
4532
+ arguments = {'scores' : scores_reduce_max ,
4533
+ 'max_output_size' : max_detections ,
4534
+ 'iou_threshold' : nms_iou_threshold ,
4535
+ 'score_threshold' : nms_score_threshold ,
4536
+ 'soft_nms_sigma' : 0.0 ,
4537
+ 'pad_to_max_output_size' : True }
4538
+ )(boxes_concat )
4539
+
4540
+ else :
4541
+ selected_indices = \
4542
+ tf .keras .layers .Lambda (
4543
+ NonMaxSuppressionV3_ ,
4544
+ arguments = {'scores' : scores_reduce_max ,
4545
+ 'max_output_size' : max_detections ,
4546
+ 'iou_threshold' : nms_iou_threshold ,
4547
+ 'score_threshold' : nms_score_threshold }
4548
+ )(boxes_concat )
4549
+ selected_scores = tf .gather (
4550
+ scores_reduce_max ,
4551
+ selected_indices
4552
+ )
4553
+ valid_outputs = max_detections
4525
4554
################################################################### Calculation of outputs
4526
4555
bounding_boxes = tf .identity (
4527
4556
tf .expand_dims (
0 commit comments