PINTO0309 / openvino2tensorflow

This script converts the ONNX/OpenVINO IR model to Tensorflow's saved_model, tflite, h5, tfjs, tftrt(TensorRT), CoreML, EdgeTPU, ONNX and pb. PyTorch (NCHW) -> ONNX (NCHW) -> OpenVINO (NCHW) -> openvino2tensorflow -> Tensorflow/Keras (NHWC/NCHW) -> TFLite (NHWC/NCHW). And the conversion from .pb to saved_model and from saved_model to .pb and from .pb to .tflite and saved_model to .tflite and saved_model to onnx. Support for building environments with Docker. It is possible to directly access the host PC GUI and the camera to verify the operation. NVIDIA GPU (dGPU) support. Intel iHD GPU (iGPU) support.
MIT License
338 stars 39 forks source link

PriorBoxClustered Not implemented #31

Closed reshmastadas closed 2 years ago

reshmastadas commented 3 years ago

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.

hesamsheikh commented 3 years ago

Is this feature going to be added? any updates about it?

PINTO0309 commented 2 years ago

work in progress. https://github.com/openvinotoolkit/openvino/blob/2021.4.1/ngraph/core/reference/include/ngraph/runtime/reference/prior_box_clustered.hpp

PINTO0309 commented 2 years ago

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)>

PINTO0309 commented 2 years ago

Fixes. However, I have not yet implemented the final layer, DetectionOutput. https://github.com/PINTO0309/openvino2tensorflow/releases/tag/v1.25.1

PINTO0309 commented 2 years ago

https://github.com/PINTO0309/openvino2tensorflow/releases/tag/v1.25.3 https://github.com/PINTO0309/openvino2tensorflow/releases/tag/v1.25.4 aaa

PINTO0309 commented 2 years ago

Commited. https://github.com/PINTO0309/PINTO_model_zoo/tree/main/179_person-detection-0202