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

Commit 43c827f

Browse files
committed
face_landmark_with_attention to OAK
1 parent 0891738 commit 43c827f

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

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.20.7",
14+
version="1.20.8",
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/mediapipeCustomOp.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def TransformLandmarks(operator, custom_options, tensors, interpreter, landmarks
7272
return landmarks2d_transformed
7373

7474
#Affine transform images using bilinear interpolation
75-
def TransformTensorBilinear(operator, custom_options, tensors, interpreter, optimizing_barracuda, features=None, mat=None):
75+
def TransformTensorBilinear(operator, custom_options, tensors, interpreter, optimizing_barracuda, optimaization_for_myriad, features=None, mat=None):
7676
if features is None:
7777
features = tensors[operator['inputs'][0]] #float32 [b,48,48,32] feature maps
7878
if mat is None:
@@ -110,8 +110,8 @@ def TransformTensorBilinear(operator, custom_options, tensors, interpreter, opti
110110
weight_floor = tf.subtract(tf.ones(2), weight_ceil_) #[b,h,w,2]
111111
weight_ceilX = tf.multiply(weight_ceil_[:,:,:,0:1], weight_floor[:,:,:,1:2]) #[b,h,w]
112112
weight_ceilY = tf.multiply(weight_floor[:,:,:,0:1], weight_ceil_[:,:,:,1:2]) #[b,h,w]
113-
weight_ceil_ = tf.reduce_prod(weight_ceil_, axis=3, keepdims=True) #[b,h,w,1]
114-
weight_floor = tf.reduce_prod(weight_floor, axis=3, keepdims=True) #[b,h,w,1]
113+
weight_ceil_ = tf.multiply(weight_ceil_[:,:,:,0:1], weight_ceil_[:,:,:,1:2]) #[b,h,w]
114+
weight_floor = tf.multiply(weight_floor[:,:,:,0:1], weight_floor[:,:,:,1:2]) #[b,h,w]
115115

116116
# Find nearest 4 points.
117117
# Make sure they are in the input image
@@ -157,7 +157,7 @@ def barracuda_gather_nd(params, indices):
157157
return tf.expand_dims(tf.reshape(result_flat, tf.concat([idx_shape[:-1], gather_shape], axis=0)), axis=0)
158158

159159
# calc final pixel value
160-
if not optimizing_barracuda:
160+
if not optimizing_barracuda and not optimaization_for_myriad:
161161
value_floor = tf.gather_nd(params=features, indices=in_coord_floor, batch_dims=1) #[b,h,w,32]
162162
value_ceilX = tf.gather_nd(params=features, indices=in_coord_ceilX, batch_dims=1) #[b,h,w,32]
163163
value_ceilY = tf.gather_nd(params=features, indices=in_coord_ceilY, batch_dims=1) #[b,h,w,32]

tflite2tensorflow/tflite2tensorflow.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3485,7 +3485,8 @@ def barracuda_gather_nd(params, indices):
34853485
result_flat = tf.gather(params_flat, indices_flat)
34863486
return tf.expand_dims(tf.reshape(result_flat, tf.concat([idx_shape[:-1], gather_shape], axis=0)), axis=0)
34873487

3488-
if not optimizing_barracuda:
3488+
optimaization_for_myriad = (optimizing_for_openvino_and_myriad and rigorous_optimization_for_myriad)
3489+
if not optimizing_barracuda and not optimaization_for_myriad:
34893490
output_tensor = tf.gather_nd(
34903491
input_tensor1,
34913492
input_tensor2,
@@ -5126,7 +5127,15 @@ def complexabs_(x, tout):
51265127
options = op['custom_options']
51275128
custom_options = read_flexbuffer(np.array(options, dtype=np.uint8).tobytes())
51285129
output_detail = interpreter._get_tensor_details(op['outputs'][0])
5129-
tensors[output_detail['index']] = TransformTensorBilinear(op, custom_options, tensors, interpreter, optimizing_barracuda)
5130+
optimaization_for_myriad = (optimizing_for_openvino_and_myriad and rigorous_optimization_for_myriad)
5131+
tensors[output_detail['index']] = TransformTensorBilinear(
5132+
op,
5133+
custom_options,
5134+
tensors,
5135+
interpreter,
5136+
optimizing_barracuda,
5137+
optimaization_for_myriad,
5138+
)
51305139

51315140
elif custom_op_type == 'TransformLandmarks':
51325141
custom_options = None

0 commit comments

Comments
 (0)