Skip to content
This repository was archived by the owner on May 12, 2024. It is now read-only.

Commit 6c8555b

Browse files
committed
Optimizing NMS for Myriad Blobs
1 parent edd516a commit 6c8555b

File tree

3 files changed

+41
-12
lines changed

3 files changed

+41
-12
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ARG CPVER=cp38
77
ARG OPENVINOVER=2021.4.582
88
ARG OPENVINOROOTDIR=/opt/intel/openvino_2021
99
ARG TENSORRTVER=cuda11.3-trt8.0.1.6-ga-20210626
10-
ARG APPVER=v1.11.5
10+
ARG APPVER=v1.11.6
1111
ARG wkdir=/home/user
1212

1313
# dash -> bash

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
setup(
1212
name="tflite2tensorflow",
1313
scripts=scripts,
14-
version="1.11.5",
14+
version="1.11.6",
1515
description="Generate saved_model, tfjs, tf-trt, EdgeTPU, CoreML, quantized tflite, ONNX, OpenVINO, Myriad Inference Engine blob and .pb from .tflite.",
1616
long_description=long_description,
1717
long_description_content_type="text/markdown",

tflite2tensorflow/tflite2tensorflow.py

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4511,17 +4511,46 @@ def NonMaxSuppressionV5_(boxes, scores, max_output_size: int, iou_threshold, sco
45114511
)
45124512
return selected_indices, selected_scores, valid_outputs
45134513

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
45244524

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
45254554
################################################################### Calculation of outputs
45264555
bounding_boxes = tf.identity(
45274556
tf.expand_dims(

0 commit comments

Comments
 (0)