背景
1.在Ubuntu22.04上安装Audio2Face后启动,嘴形不会实时同步。控制台显示如【图一】:
【图一】
2.log日志如下:
Error: Error during running command: [‘/home/admin/omniverse/libs/deps/321b626abba810c3f8d1dd4d247d2967/exts/omni.audio2face.inference_deps/deps/audio2face-inference-deps/bin/trtexec’, ‘–onnx=/home/admin/omniverse/libs/deps/321b626abba810c3f8d1dd4d247d2967/exts/omni.audio2face.emotion_deps/deps/audio2emotion-nets/nets/a2e_v1.4.2/network.onnx’, ‘–saveEngine=/home/admin/omniverse/cache/Kit/105.1/c677816d/audio2emotion-nets/a2e_v1.4.2/network_device0_fp32.trt’, ‘–device=0’, ‘–tacticSources=-CUDNN’, ‘–explicitBatch’]`
根据提示,直接在终端运行该命令:
/home/admin/omniverse/libs/deps/321b626abba810c3f8d1dd4d247d2967/exts/omni.audio2face.inference_deps/deps/audio2face-inference-deps/bin/trtexec --onnx=/home/admin/omniverse/libs/deps/321b626abba810c3f8d1dd4d247d2967/exts/omni.audio2face.emotion_deps/deps/audio2emotion-nets/nets/a2e_v1.4.2/network.onnx --saveEngine=/home/admin/omniverse/cache/Kit/105.1/c677816d/audio2emotion-nets/a2e_v1.4.2/network_device0_fp32.trt --device=0 --tacticSources=-CUDNN --explicitBatch
果然没有失望,报错如下:
Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
不难看出,Nvidia提供的audio2emotion network.onnx为INT64.需要将模型转化为INIT32后重新构建TensorRT Engine即可。
接下来,需要将network.onnx的精度从INT64转化为INT32。
安装onnx-simplifier
pip install onnx-simplifier
根据上面的log,在/home/admin/omniverse/libs/deps/321b626abba810c3f8d1dd4d247d2967/exts/omni.audio2face.emotion_deps/deps/audio2emotion-nets/nets/a2e_v1.4.2/network.onnx
找到network.onnx
文件
转化模型为INT32:
cd /home/admin/omniverse/libs/deps/321b626abba810c3f8d1dd4d247d2967/exts/omni.audio2face.emotion_deps/deps/audio2emotion-nets/nets/a2e_v1.4.2/
# 转化INT64->INT32
python -m onnxsim network.onnx networkfp32.onnx
# 将转化后的networkfp32.onnx重命令为network.onnx,不然audio2face build TensorRT Engine时找不到。
mv network.onnx networkfp64.onnx
mv networkfp32.onnx network.onnx
重新构建TensorRT
如图二进行重构即可,重构成功后的AUTO-EMOTION控制面板如图三:
【图二】
【图三】
PS:如果自己已经安装过TensorRT,也可以用自己的trtexec进行转化,不过不建议这样做,因为要和Audio2Face中的trtexec(即log中的文件【/home/admin/omniverse/libs/deps/321b626abba810c3f8d1dd4d247d2967/exts/omni.audio2face.inference_deps/deps/audio2face-inference-deps/bin/trtexec】)版本一致。