Unity-Technologies / barracuda-release

Other
568 stars 78 forks source link

Model that runs fine in onnxruntime throws warning and gives incorrect results in barracuda #271

Closed matthiasseibold closed 2 years ago

matthiasseibold commented 2 years ago

Hi all,

I've been trying to port the following code to barracuda (Unity 2020.3.31f1 with Barracuda 3.0.0.): https://github.com/ibaiGorordo/ONNX-Mobile-Human-Pose-3D

The model can be imported correctly in onnxruntime, but shows the following warnings in the inspector:

Warnings 3
595 Unsupported attribute nearest_mode, node 595 of type Resize. Value will be ignored and defaulted to round_prefer_floor.
609 Unsupported attribute nearest_mode, node 609 of type Resize. Value will be ignored and defaulted to round_prefer_floor.
623 Unsupported attribute nearest_mode, node 623 of type Resize. Value will be ignored and defaulted to round_prefer_floor.

The onnx model can be downloaded here: https://drive.google.com/uc?export=download&id=1vvjUsP_41Nqhj8oqRw2OpWjIdz8t5fxG

I can run the model in barracuda, but the results differ from the ones generated in onnxruntime.


Furthermore, I've tried to convert the original TFLITE model provided by the authors https://github.com/tucan9389/PoseEstimation-TFLiteSwift/releases/download/v2.1.0/lightweight_baseline_choi.tflite to ONNX using https://github.com/onnx/tensorflow-onnx

and the command python -m tf2onnx.convert --opset 13 --tflite tflite--file --output model.onnx

The resulting model again runs fine in python with onnxruntime but this time I cannot import the model to unity, it throws the error:

Asset import failed, "Assets/Models/model.onnx" > OnnxImportException: Unexpected error while parsing layer split_1 of type Split.
Unsupported default attribute `split` for node split_1 of type Split. Value is required.

Is there any way to make the model run in barracuda? Any help would be greatly appreciated!

Thanks, Matthias

rfilkov commented 2 years ago

Any update on this one?

FlorentGuinier commented 2 years ago

Hi @rfilkov

Furthermore, I've tried to convert the original TFLITE model provided by the authors ... python -m tf2onnx.convert --opset 13 --tflite tflite--file --output model.onnx

Indeed at the moment Barracuda does not support the "split" optional parameter from Split operator version 13. We are currently extending Barracuda range of supported operators and architectures however we don't have ETA to share yet. Something to try is to export the model as opset 9. Witch is at the moment a good target version in term of supported operator for Barracuda.

Opset 9 would mean Split will be version 2 https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Split-2 Opset 11/Split 11 is also without the "split" optional parameters https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Split-11

FlorentGuinier commented 2 years ago

In regard to pose estimation for Barracuda this ressource can be helpfull imho: https://github.com/keijiro/BodyPixBarracuda

matthiasseibold commented 2 years ago

Thank you for the reply!

With opset 9 I get the same error when trying to import the ONNX model in python, I use the command:

python -m tf2onnx.convert --opset 9 --tflite lightweight_baseline_choi.tflite --output model_opset_9.onnx

and get the error:

OnnxImportException: Unexpected error while parsing layer split_1 of type Split.
Unsupported default attribute `split` for node split_1 of type Split. Value is required.

Is there any feedback about the warnings of the original onnx model that I was trying to import (in my first post)?

matthiasseibold commented 2 years ago

In regard to pose estimation for Barracuda this ressource can be helpfull imho: https://github.com/keijiro/BodyPixBarracuda

thanks, but this does not seem to support 3D human pose estimation.

However, in the meantime I found a repository that contains a working example of 3D human pose estimation using a VRect onnx model with barracuda: https://github.com/digital-standard/ThreeDPoseUnityBarracuda