PINTO0309 / PINTO_model_zoo

A repository for storing models that have been inter-converted between various frameworks. Supported frameworks are TensorFlow, PyTorch, ONNX, OpenVINO, TFJS, TFTRT, TensorFlowLite (Float32/16/INT8), EdgeTPU, CoreML.
https://qiita.com/PINTO
MIT License
3.62k stars 577 forks source link

BlazePose landmark detection is inaccurate #84

Closed aylek closed 3 years ago

aylek commented 3 years ago

1. OS you are using e.g. Ubuntu 20.04, WIndows10, etc

Fedora 28

2. OS Architecture e.g. x86_64, armv7l, aarch64, etc

x86_64

3. Version of OpenVINO e.g. 2021.2.185, etc

4. Version of TensorFlow e.g. v2.4.1, tf-nightly==2.5.0.dev20210128, etc

v2.3.1

5. Version of TensorRT e.g. TensorRT6.0 GA, etc

6. Version of TFJS e.g. 1.5.0, etc

7. Version of coremltools e.g. 4.0, etc

8. Version of ONNX e.g. v1.8.0, etc

9. URL of the repository from which the transformed model was taken

https://github.com/PINTO0309/PINTO_model_zoo/tree/main/053_BlazePose/03_pose_landmark_full_body

10. URL or source code for simple inference testing code

import numpy as np
import cv2
import tensorflow as tf

model_path = './PINTO_model_zoo/053_BlazePose/03_pose_landmark_full_body/saved_model_tflite_tfjs_coreml_onnx'

test_image_path = './mpii/images/000005283.jpg'

_img = cv2.imread(test_image_path, -1)

_img = cv2.cvtColor(_img, cv2.COLOR_BGR2RGB)

img = cv2.resize(_img, (256, 256))

model = tf.keras.models.load_model(model_path)

sig = model.signatures['serving_default']

x = np.float32(np.expand_dims(img, 0)) / 255.

output = sig(tf.constant(x))['ld_3d'].numpy().squeeze()

key_points = []
for x, y in zip(output[::5], output[1::5]):
    print(f'{x}, {y}')
    key_points.append((int(x / 255. * _img.shape[1]), int(y / 255. * _img.shape[0])))

for i in range(33):
    cv2.circle(_img, center=key_points[i], radius=2, color=(0, 255, 0), thickness=2)

cv2.imshow("test", _img)
cv2.waitKey(0)

11. Issue Details

Detected landmarks are inaccurate when attempting to predict on the aforementioned test image and the full body SavedModel (PINTO_model_zoo/053_BlazePose/03_pose_landmark_full_body/saved_model_tflite_tfjs_coreml_onnx) model. I get similar results with the equivalent TensorFlow Lite models.

I'm not sure if I'm missing something in my test script, but it is the result of what i was able to gather based on examples found here and in the MediaPipe sources.

Test image:

000005283

Landmarks detected using test script:

test_screenshot_25 03 2021

Landmarks detected using MediaPipe's python api:

annotated_image0

PINTO0309 commented 3 years ago

Please take a look here. It doesn't look like a problem. https://github.com/geaxgx/depthai_blazepose.git