Closed reshmastadas closed 2 years ago
Is this feature going to be added? any updates about it?
OpenVINO (.xml / .bin)
Convert to TensorFlow
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '-1'
import tensorflow as tf
from pprint import pprint
import numpy as np
np.random.seed(0)
clip = False height = [25.7671, 51.5625, 80.9276, 114.398] width = [7.89083, 16.9053, 22.8718, 31.2677] img_h = 0 img_w = 0 offset = 0.5 step = 0 step_h = 16 step_w = 16 variance = [0.1, 0.1, 0.2, 0.2]
i1 = np.asarray([32,32]) i2 = np.asarray([512,512])
layer_width = i1[1] layer_height = i1[0] img_width = i2[1] img_height = i2[0]
num_priors = len(width) if not variance: variance = [0.1] var_size = len(variance)
step_w = step if step_w == 0 else step_w step_h = step if step_h == 0 else step_h if (step_w == 0 and step_h == 0): step_w = img_width / layer_width step_h = img_height / layer_height
out_shape = [2, 4 layer_height layer_width * num_priors] dst_data = np.zeros((out_shape), dtype=np.float32).flatten()
for h in range(layer_height): for w in range(layer_width): center_x = (w + offset) step_w center_y = (h + offset) step_h for s in range(num_priors): box_width = width[s] box_height = height[s] xmin = (center_x - box_width / 2.0) / img_width ymin = (center_y - box_height / 2.0) / img_height xmax = (center_x + box_width / 2.0) / img_width ymax = (center_y + box_height / 2.0) / img_height if clip: xmin = min(max(xmin, 0.0), 1.0) ymin = min(max(ymin, 0.0), 1.0) xmax = min(max(xmax, 0.0), 1.0) ymax = min(max(ymax, 0.0), 1.0) def get_idx(cnt): return h layer_width num_priors cnt + w num_priors cnt + s cnt idx = get_idx(4) dst_data[idx + 0] = xmin dst_data[idx + 1] = ymin dst_data[idx + 2] = xmax dst_data[idx + 3] = ymax idx = get_idx(var_size) for j in range(var_size): dst_data[idx + j + out_shape[1]] = variance[j]
print('@@@@@@@@@@@ dst_data') pprint(dst_data) out = tf.constant(dst_data) out_reshape = tf.reshape(out, shape=out_shape) print('@@@@@@@@@@@ dst_data reshape') pprint(out_reshape)
@@@@@@@@@@@ dst_data array([ 0.00791911, -0.00953818, 0.02333089, ..., 0.1 , 0.2 , 0.2 ], dtype=float32)
@@@@@@@@@@@ dst_data reshape <tf.Tensor: shape=(2, 16384), dtype=float32, numpy= array([[ 0.00791911, -0.00953818, 0.02333089, ..., 0.8726582 , 1.0149099 , 1.0960917 ], [ 0.1 , 0.1 , 0.2 , ..., 0.1 , 0.2 , 0.2 ]], dtype=float32)>
Fixes. However, I have not yet implemented the final layer, DetectionOutput
.
https://github.com/PINTO0309/openvino2tensorflow/releases/tag/v1.25.1
Hello,
When I tried to convert person-detection-0202 to .pb model, I got the following error
The PriorBoxClustered layer is not yet implemented.
Kindly have a look at it.