From 23fc058ac64d82ab2e6ee7aa7dd19d0ba3a0c0f0 Mon Sep 17 00:00:00 2001 From: zpeng11 Date: Tue, 3 Feb 2026 01:11:08 -0500 Subject: [PATCH] feat:export release --- 01A.启动器.bat | 6 + 01B.启动器(调试输出).bat | 8 + 02A.启动器.bat | 6 - 02B.启动器(调试输出).bat | 8 - 03.构建tha4的ONNX和TensorRT学生模型.bat | 74 ----- README.md | 27 +- launcher2.py | 2 +- pack_release.bat | 80 +++--- requirements.txt | 1 - src/ezvtb_rt_interface.py | 11 +- test.py | 258 ------------------ .../onnx_export_tha4.py | 0 .../onnx_export_tha4_student.py | 0 .../test_tha4_student.py | 0 tha4_adapter.py => tha4/tha4_adapter.py | 0 .../tha4_convert_onnx_to_trt.py | 0 tha4_core.py => tha4/tha4_core.py | 0 tha4_core_old.py => tha4/tha4_core_old.py | 0 .../tha4_student_convert_onnx_to_trt.py | 0 19 files changed, 78 insertions(+), 403 deletions(-) create mode 100644 01A.启动器.bat create mode 100644 01B.启动器(调试输出).bat delete mode 100644 02A.启动器.bat delete mode 100644 02B.启动器(调试输出).bat delete mode 100644 03.构建tha4的ONNX和TensorRT学生模型.bat delete mode 100644 test.py rename onnx_export_tha4.py => tha4/onnx_export_tha4.py (100%) rename onnx_export_tha4_student.py => tha4/onnx_export_tha4_student.py (100%) rename test_tha4_student.py => tha4/test_tha4_student.py (100%) rename tha4_adapter.py => tha4/tha4_adapter.py (100%) rename tha4_convert_onnx_to_trt.py => tha4/tha4_convert_onnx_to_trt.py (100%) rename tha4_core.py => tha4/tha4_core.py (100%) rename tha4_core_old.py => tha4/tha4_core_old.py (100%) rename tha4_student_convert_onnx_to_trt.py => tha4/tha4_student_convert_onnx_to_trt.py (100%) diff --git a/01A.启动器.bat b/01A.启动器.bat new file mode 100644 index 0000000..8fa5cf0 --- /dev/null +++ b/01A.启动器.bat @@ -0,0 +1,6 @@ +@echo on +cd /D "%~dp0" + +SET PATH=%~dp0envs\TensorRT-RTX-1.3.0.35_cu129\bin;%~dp0envs\python_embedded;%~dp0envs\python_embedded\Scripts;%~dp0envs\python_embedded\Library\bin;%PATH% + +pythonw launcher2.py \ No newline at end of file diff --git a/01B.启动器(调试输出).bat b/01B.启动器(调试输出).bat new file mode 100644 index 0000000..453f60c --- /dev/null +++ b/01B.启动器(调试输出).bat @@ -0,0 +1,8 @@ +@echo on +cd /D "%~dp0" + +SET PATH=%~dp0envs\TensorRT-RTX-1.3.0.35_cu129\bin;%~dp0envs\python_embedded;%~dp0envs\python_embedded\Scripts;%~dp0envs\python_embedded\Library\bin;%PATH% + +python launcher2.py + +pause \ No newline at end of file diff --git a/02A.启动器.bat b/02A.启动器.bat deleted file mode 100644 index 09c6fc0..0000000 --- a/02A.启动器.bat +++ /dev/null @@ -1,6 +0,0 @@ -@echo on -cd /D "%~dp0" - -SET PATH=%~dp0envs\python_embedded;%~dp0envs\python_embedded\Scripts;%~dp0envs\python_embedded\Library\bin;%PATH% - -pythonw launcher2.py \ No newline at end of file diff --git a/02B.启动器(调试输出).bat b/02B.启动器(调试输出).bat deleted file mode 100644 index d35ae38..0000000 --- a/02B.启动器(调试输出).bat +++ /dev/null @@ -1,8 +0,0 @@ -@echo on -cd /D "%~dp0" - -SET PATH=%~dp0envs\python_embedded;%~dp0envs\python_embedded\Scripts;%~dp0envs\python_embedded\Library\bin;%PATH% - -python launcher2.py - -pause \ No newline at end of file diff --git a/03.构建tha4的ONNX和TensorRT学生模型.bat b/03.构建tha4的ONNX和TensorRT学生模型.bat deleted file mode 100644 index f7261fa..0000000 --- a/03.构建tha4的ONNX和TensorRT学生模型.bat +++ /dev/null @@ -1,74 +0,0 @@ -@echo off -setlocal enabledelayedexpansion -cd /D "%~dp0" - -SET PATH=%~dp0envs\python_embedded;%~dp0envs\python_embedded\Scripts;%~dp0envs\python_embedded\Library\bin;%PATH% - -echo ================================================================================ -echo THA4 ѧÉúģÐÍ ONNX ºÍ TensorRT ת»»¹¤¾ß -echo ================================================================================ -echo. - -REM ¼ì²éģÐÍĿ¼ÊǷñ´æÔÚ -if not exist "data\models\custom_tha4_models" ( - echo [´íÎó] ÕҲ»µ½ģÐÍĿ¼: data\models\custom_tha4_models - pause - exit /b 1 -) - -echo ¿ÉÓõÄ THA4 ѧÉúģÐÍ: -echo -------------------------------------------------------------------------------- -set count=0 -for /d %%i in (data\models\custom_tha4_models\*) do ( - set /a count+=1 - echo [!count!] %%~nxi -) -echo -------------------------------------------------------------------------------- -echo. - -if %count%==0 ( - echo [´íÎó] δÕҵ½ÈκÎģÐÍÎļþ¼Ð - pause - exit /b 1 -) - -echo ÇëÊäÈëҪת»»µÄģÐÍÎļþ¼ÐÃû³Æ: -set /p MODEL_NAME=^> - -REM ¼ì²éÊäÈëÊǷñΪ¿Õ -if "%MODEL_NAME%"=="" ( - echo [´íÎó] ģÐÍÃû³Ʋ»ÄÜΪ¿Õ - pause - exit /b 1 -) - -REM ¼ì²éģÐÍÎļþ¼ÐÊǷñ´æÔÚ -if not exist "data\models\custom_tha4_models\%MODEL_NAME%" ( - echo [´íÎó] ģÐÍÎļþ¼в»´æÔÚ: data\models\custom_tha4_models\%MODEL_NAME% - pause - exit /b 1 -) - -echo. -echo ================================================================================ -echo ²½Öè 1/2: µ¼³ö ONNX ģÐÍ -echo ================================================================================ -echo ģÐÍ: %MODEL_NAME% -echo ÃüÁî: python onnx_export_tha4_student.py %MODEL_NAME% --cpu -echo -------------------------------------------------------------------------------- -echo. - -python onnx_export_tha4_student.py %MODEL_NAME% --cpu - -echo ================================================================================ -echo ²½Öè 2/2: ת»»Ϊ TensorRT ģÐÍ -echo ================================================================================ -echo ģÐÍ: %MODEL_NAME% -echo ÃüÁî: python tha4_student_convert_onnx_to_trt.py %MODEL_NAME% fp32 -echo -------------------------------------------------------------------------------- -echo. - -python tha4_student_convert_onnx_to_trt.py %MODEL_NAME% fp32 - -pause - diff --git a/README.md b/README.md index 1d4138e..989ca5d 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Updates: * 使用 [waifu2x](https://github.com/nagadomi/waifu2x) 和 [real-esrgan](https://github.com/xinntao/Real-ESRGAN) 项目带来的输出超分辨率,对比anime4k效果提升显著(也使用更多gpu占用) * 更漂亮的 WxPython 新启动器界面,带中文介绍更加简单易用 * 添加Spout2 支持输出原生透明通道给OBS +* 添加 [THA V4](https://github.com/pkhungurn/talking-head-anime-4-demo) 支持,拥有更好的图形输出 ## Requirements @@ -43,7 +44,7 @@ Updates: 使用Spout2插件可以提供透明通道给OBS,访问 https://github.com/Off-World-Live/obs-spout2-plugin/releases 项目,请选择与你的OBS版本兼容的插件安装exe。 ### 启动项目 -双击`02A.启动器.bat` 或 `02B.启动器(调试输出).bat` 启动器,如下图启动。 +双击`01A.启动器.bat` 或 `01B.启动器(调试输出).bat` 启动器,如下图启动。 ![](assets/02success.png) 之后请移步后文的输入输出&性能配置板块自行调节。如有问题请先参考本页末的FAQ再提出。 @@ -240,3 +241,27 @@ A卡I卡使用 DirectML,这个框架与显卡厂商的显卡驱动及 Direct12 > Q6: 本机有两张显卡,如何使用第二张副卡使用这个项目? 在运行前配置环境变量`EZVTB_DEVICE_ID`为你想要运行的GPU ID,此变量缺省为`0` + +## References +``` +@inproceedings{huang2022rife, + title={Real-Time Intermediate Flow Estimation for Video Frame Interpolation}, + author={Huang, Zhewei and Zhang, Tianyuan and Heng, Wen and Shi, Boxin and Zhou, Shuchang}, + booktitle={Proceedings of the European Conference on Computer Vision (ECCV)}, + year={2022} +} +@misc{Khungurn:2022, + author = {Pramook Khungurn}, + title = {Talking Head(?) Anime from a Single Image 3: Now the Body Too}, + howpublished = {\url{http://pkhungurn.github.io/talking-head-anime-3/}}, + year = 2022, + note = {Accessed: YYYY-MM-DD}, +} + +@InProceedings{wang2021realesrgan, + author = {Xintao Wang and Liangbin Xie and Chao Dong and Ying Shan}, + title = {Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data}, + booktitle = {International Conference on Computer Vision Workshops (ICCVW)}, + date = {2021} +} +``` \ No newline at end of file diff --git a/launcher2.py b/launcher2.py index b798028..6d0edbb 100644 --- a/launcher2.py +++ b/launcher2.py @@ -318,7 +318,7 @@ class LauncherPanel(wx.Panel): addOption('beta', title='Beta', desc='输入滤波速度补偿,\n越小越平滑,越大运动时越灵敏', type=3, mapper=beta_mapper) - addOption('breath_cycle', title='Breath Cycle', desc='设置呼吸循环时间', + addOption('breath_cycle', title='Breath Cycle', desc='设置呼吸循环时间(会增加占用)', choices=['No Breath', '3 seconds', '5 seconds', '7 seconds'], mapping=['inf', '3.0', '5.0', '7.0']) diff --git a/pack_release.bat b/pack_release.bat index 747e7df..922dd7b 100644 --- a/pack_release.bat +++ b/pack_release.bat @@ -6,61 +6,49 @@ REM 2. Rebase with the latest changes: git rebase main REM ======================================================================== cd /D "%~dp0" -@REM git clean -fdx -@REM git submodule update --init --recursive -@REM if not exist "envs" mkdir envs -@REM if not exist "envs\miniconda3" mkdir envs\miniconda3 +if not exist "envs" mkdir envs +if not exist "envs\miniconda3" mkdir envs\miniconda3 -@REM IF not EXIST %~dp0envs\miniconda3\Scripts ( -@REM @RD /S /Q %~dp0envs\miniconda3 -@REM mkdir %~dp0envs\miniconda3 -@REM echo "Downloading miniconda..." -@REM powershell -Command "Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-py310_24.9.2-0-Windows-x86_64.exe' -OutFile '.\envs\miniconda3.exe' -UseBasicParsing -Headers @{'User-Agent'='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36'}" +IF not EXIST %~dp0envs\TensorRT-RTX-1.3.0.35_cu129\bin ( + @RD /S /Q %~dp0envs\TensorRT-RTX-1.3.0.35_cu129 + cd /D "%~dp0\envs" + curl -L -o trt_rtx.zip https://developer.nvidia.com/downloads/trt/rtx_sdk/secure/1.3/TensorRT-RTX-1.3.0.35-win10-amd64-cuda-12.9-Release-external.zip + tar -xf trt_rtx.zip "TensorRT-RTX-1.3.0.35" && ren "TensorRT-RTX-1.3.0.35" "TensorRT-RTX-1.3.0.35_cu129" && del trt_rtx.zip + cd /D "%~dp0" +) -@REM echo "Installling minconda..." -@REM start /wait "" %~dp0envs\miniconda3.exe /S /AddToPath=0 /RegisterPython=0 /InstallationType=JustMe /D=%~dp0envs\miniconda3 -@REM echo "Successfully install minconda" -@REM del envs\miniconda3.exe -@REM ) +IF not EXIST %~dp0envs\miniconda3\Scripts ( + @RD /S /Q %~dp0envs\miniconda3 + mkdir %~dp0envs\miniconda3 + echo "Downloading miniconda..." + powershell -Command "Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-py310_24.9.2-0-Windows-x86_64.exe' -OutFile '.\envs\miniconda3.exe' -UseBasicParsing -Headers @{'User-Agent'='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36'}" -@REM SET PATH=%~dp0envs\miniconda3\Scripts;%PATH% + echo "Installling minconda..." + start /wait "" %~dp0envs\miniconda3.exe /S /AddToPath=0 /RegisterPython=0 /InstallationType=JustMe /D=%~dp0envs\miniconda3 + echo "Successfully install minconda" + del envs\miniconda3.exe +) -@REM call activate -@REM call conda env list -@REM call conda update -y --all -@REM call conda create -n ezvtb_rt_venv_release -c conda-forge conda-pack python=3.10 -y -@REM call conda activate ezvtb_rt_venv_release -@REM call conda env list +SET PATH=%~dp0envs\TensorRT-RTX-1.3.0.35_cu129\bin;%~dp0envs\miniconda3\Scripts;%PATH% -@REM call conda install -y -c conda-forge cudatoolkit=12.9.1 cudnn=12.9.1 -@REM call conda install -y nvidia/label/cuda-12.9.1::cuda-nvcc-dev_win-64 -@REM call conda install -y pycuda -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ +call activate +call conda env list +call conda update -y --all +call conda create -n ezvtb_rt_venv_release python=3.10 -y +call conda activate ezvtb_rt_venv_release +call conda env list -@REM call conda-pack -n ezvtb_rt_venv_release -o %~dp0envs\python_embedded --format no-archive +call conda install -y conda-pack +call conda install -y conda-forge::pycuda +call conda install -y -c nvidia/label/cuda-12.9.1 cuda-nvcc-dev_win-64 cudnn cuda-runtime + +call conda-pack -n ezvtb_rt_venv_release -o %~dp0envs\python_embedded --format no-archive -@REM SET PATH=%~dp0envs\python_embedded;%~dp0envs\python_embedded\Scripts;%~dp0envs\python_embedded\Library\bin;%PATH% +SET PATH=%~dp0envs\python_embedded;%~dp0envs\python_embedded\Scripts;%~dp0envs\python_embedded\Library\bin;%PATH% +call python -m pip install %~dp0envs\TensorRT-RTX-1.3.0.35_cu129\python\tensorrt_rtx-1.3.0.35-cp310-none-win_amd64.whl +call python -m pip install -r requirements.txt --no-warn-script-location -@REM call python -m pip install --upgrade pip wheel -i https://mirrors.aliyun.com/pypi/simple/ -@REM echo yes|python -m pip install nvidia-cudnn-cu12 -i https://mirrors.aliyun.com/pypi/simple/ - -@REM echo yes|pip install tensorrt_cu12_libs==10.11.0.33 tensorrt_cu12_bindings==10.11.0.33 tensorrt==10.11.0.33 --extra-index-url https://pypi.nvidia.com - -@REM call python -m pip install -r requirements.txt --no-warn-script-location -i https://mirrors.aliyun.com/pypi/simple/ - -@REM if not exist "data\models" mkdir data\models -@REM echo "Downloading model zip file..." -@REM powershell -Command "(New-Object Net.WebClient).DownloadFile('https://github.com/zpeng11/ezvtuber-rt/releases/download/0.0.1/20241220.zip', '.\data\models\model.zip')" -@REM echo "Unzipping model zip file..." -@REM powershell -Command "Expand-Archive -Path '.\data\models\model.zip' -DestinationPath '.\data\models\temp' -Force; Move-Item -Path '.\data\models\temp\20241220\*' -Destination '.\data\models\' -Force; Remove-Item -Path '.\data\models\temp' -Recurse -Force" -@REM del .\data\models\model.zip - -@REM @REM To verify if environment works -@REM call python ezvtb_rt_interface.py - -@REM Clean up step -echo "Cleaning up .trt files in data\models directory..." -for /R %~dp0data\models %%f in (*.trt) do del "%%f" @RD /S /Q %~dp0envs\miniconda3 pause \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 4671f68..1503fd9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ numpy scipy -matplotlib protobuf pynput mediapipe==0.10.11 diff --git a/src/ezvtb_rt_interface.py b/src/ezvtb_rt_interface.py index b68ab2b..09204a2 100644 --- a/src/ezvtb_rt_interface.py +++ b/src/ezvtb_rt_interface.py @@ -1,6 +1,6 @@ import os import sys - +from .args import args dir_path = os.path.dirname(os.path.realpath(__file__)) ezvtb_path = os.path.join(dir_path, "..", "ezvtuber-rt") ezvtb_main_path = os.path.join(dir_path, "..", 'ezvtuber-rt-main') @@ -45,6 +45,7 @@ def get_core( from ezvtb_rt.core_trt import CoreTRT as Core except: print("TensorRT is not available, fallback to ONNX Runtime.") + args.use_tensorrt = False from ezvtb_rt.core_ort import CoreORT as Core else: from ezvtb_rt.core_ort import CoreORT as Core @@ -68,10 +69,4 @@ def get_core( use_eyebrow=model_use_eyebrow, ) return core - -if __name__ == '__main__': - try: - from ezvtb_rt.trt_utils import check_build_all_models - check_build_all_models() - except: - print("TensorRT not available, skip building TRT models.") \ No newline at end of file + \ No newline at end of file diff --git a/test.py b/test.py deleted file mode 100644 index 2ae533f..0000000 --- a/test.py +++ /dev/null @@ -1,258 +0,0 @@ -# from pyanime4k import ac -# import pyanime4k -# -# parameters = ac.Parameters() -# # enable HDN for ACNet -# parameters.HDN = True -# -# a = ac.AC( -# type=ac.ProcessorType.CPU_ACNet, -# ) -# a.set_arguments(parameters) -import struct - -import cv2 -# -# img = cv2.imread("character/test41.png") -# -# a.load_image_from_numpy(img,input_type=ac.AC_INPUT_BGR) -# -# a.get_processor_info() -# -# # start processing -# a.process() -# -# a.show_image() - -# import numpy as np -# import zlib -# import bz2 -# import lzma -# import time -# -# postprocessed_image=np.load('out.npy') -# tic=time.perf_counter() -# res=None -# for i in range(100): -# res=zlib.compress(postprocessed_image) -# print("zlib", len(res),(time.perf_counter() - tic) * 1000) -# tic = time.perf_counter() -# for i in range(100): -# zlib.decompress(res) -# print("zlib", len(res),(time.perf_counter() - tic) * 1000) -# tic = time.perf_counter() -# for i in range(100): -# res=bz2.compress(postprocessed_image) -# print("bz2",len(res), (time.perf_counter() - tic) * 1000) -# tic = time.perf_counter() -# for i in range(100): -# bz2.decompress(res) -# print("bz2", len(res),(time.perf_counter() - tic) * 1000) -# tic = time.perf_counter() -# for i in range(100): -# res=lzma.compress(postprocessed_image) -# print("lzma",len(res), (time.perf_counter() - tic) * 1000) -# tic = time.perf_counter() -# for i in range(100): -# lzma.decompress(res) -# print("lzma", len(res),(time.perf_counter() - tic) * 1000) -# tic = time.perf_counter() -# -# -# output_frame = cv2.cvtColor(postprocessed_image, cv2.COLOR_RGBA2BGRA) -# cv2.imshow("frame", output_frame) -# cv2.waitKey(100000) -# preview upscaled image -# img=a.save_image_to_numpy() -# -# print(img) -# import cv2 -# import numpy as np -# -# rgb=[ -# [[1,2,3],[2,2,3],[3,2,3],[4,2,3]], -# [[1,2,3],[2,2,3],[3,2,3],[4,2,3]], -# [[1,2,3],[2,2,3],[3,2,3],[4,2,3]], -# [[1,2,3],[2,2,3],[3,2,3],[4,2,3]] -# ] -# a=[ -# [1,2,3,4], -# [1,2,3,4], -# [1,2,3,4], -# [1,2,3,4], -# ] -# -# print(cv2.merge((np.array(rgb),np.array(a)))) - - -from multiprocessing import Value, Process, Queue -import queue -import socket -import errno -import time -import tha2.poser.modes.mode_20_wx -from tha2.mocap.ifacialmocap_constants import * -import numpy as np - -ifm='127.0.0.1:11573' - - - -class ClientProcess(Process): - def __init__(self): - super().__init__() - self.queue = Queue() - self.should_terminate = Value('b', False) - self.address = ifm.split(':')[0] - self.port = int(ifm.split(':')[1]) - self.perf_time = 0 - # self.ifm_converter = tha2.poser.modes.mode_20_wx.create_ifacialmocap_pose_converter() - self.a_min=None - self.a_max=None - - def run(self): - self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - self.socket.setblocking(False) - self.socket.bind(("", self.port)) - self.socket.settimeout(0.1) - while True: - if self.should_terminate.value: - break - try: - socket_bytes = self.socket.recv(8192) - except socket.error as e: - err = e.args[0] - if err == errno.EAGAIN or err == errno.EWOULDBLOCK or err == 'timed out': - continue - else: - raise e - - # socket_string = socket_bytes.decode("utf-8") - osf_raw=(struct.unpack('=di2f2fB1f4f3f3f68f136f210f14f',socket_bytes)) - # print(osf_raw[432:]) - data={} - OpenSeeDataIndex=[ - 'time', - 'id', - 'cameraResolutionW', - 'cameraResolutionH', - 'rightEyeOpen', - 'leftEyeOpen', - 'got3DPoints', - 'fit3DError', - 'rawQuaternionX', - 'rawQuaternionY', - 'rawQuaternionZ', - 'rawQuaternionW', - 'rawEulerX', - 'rawEulerY', - 'rawEulerZ', - 'translationY', - 'translationX', - 'translationZ', - ] - for i in range(len(OpenSeeDataIndex)): - data[OpenSeeDataIndex[i]]=osf_raw[i] - data['translationY']*=-1 - data['translationZ']*=-1 - data['rotationY']=data['rawEulerY'] - data['rotationX']=(-data['rawEulerX']+180)%360 - data['rotationZ']=(data['rawEulerZ']-90) - OpenSeeFeatureIndex=[ - 'EyeLeft', - 'EyeRight', - 'EyebrowSteepnessLeft', - 'EyebrowUpDownLeft', - 'EyebrowQuirkLeft', - 'EyebrowSteepnessRight', - 'EyebrowUpDownRight', - 'EyebrowQuirkRight', - 'MouthCornerUpDownLeft', - 'MouthCornerInOutLeft', - 'MouthCornerUpDownRight', - 'MouthCornerInOutRight', - 'MouthOpen', - 'MouthWide' - ] - - for i in range(68): - data['confidence'+str(i)]=osf_raw[i+18] - for i in range(68): - data['pointsX'+str(i)]=osf_raw[i*2+18+68] - data['pointsY'+str(i)]=osf_raw[i*2+18+68+1] - for i in range(70): - data['points3DX'+str(i)]=osf_raw[i*3+18+68+68*2] - data['points3DY'+str(i)]=osf_raw[i*3+18+68+68*2+1] - data['points3DZ'+str(i)]=osf_raw[i*3+18+68+68*2+2] - - for i in range(len(OpenSeeFeatureIndex)): - data[OpenSeeFeatureIndex[i]]=osf_raw[i+432] - # print(data['rotationX'],data['rotationY'],data['rotationZ']) - - a=np.array([ - data['points3DX66']-data['points3DX68']+data['points3DX67']-data['points3DX69'], - data['points3DY66']-data['points3DY68']+data['points3DY67']-data['points3DY69'], - data['points3DZ66']-data['points3DZ68']+data['points3DZ67']-data['points3DZ69'] - ]) - a=(a/np.linalg.norm(a)) - data['eyeRotationX']=a[0] - data['eyeRotationY']=a[1] - # blender_data = json.loads(socket_string) - # data = self.convert_from_blender_data(socket_string) - # data=self.ifm_converter.convert(data) - # print(data) - # if(self.a_max is None): - # self.a_max=[x for x in data] - # else: - # self.a_max=[max(data[i],self.a_max[i]) for i in range(len(data))] - # if(self.a_min is None): - # self.a_min=[x for x in data] - # else: - # self.a_min=[min(data[i],self.a_min[i]) for i in range(len(data))] - # print([[self.a_min[i],self.a_max[i]] for i in range(len(data))]) - cur_time = time.perf_counter() - fps = 1 / (cur_time - self.perf_time) - self.perf_time = cur_time - # print(fps) - try: - self.queue.put_nowait(data) - except queue.Full: - pass - self.queue.close() - self.socket.close() - @staticmethod - def convert_from_blender_data(blender_data): - data = {} - - for item in blender_data.split('|'): - if item.find('#') != -1: - k, arr = item.split('#') - arr = [float(n) for n in arr.split(',')] - data[k.replace("_L", "Left").replace("_R", "Right")] = arr - elif item.find('-') != -1: - k, v = item.split("-") - data[k.replace("_L", "Left").replace("_R", "Right")] = float(v) / 100 - - to_rad = 57.3 - data[HEAD_BONE_X] = data["=head"][0] / to_rad - data[HEAD_BONE_Y] = data["=head"][1] / to_rad - data[HEAD_BONE_Z] = data["=head"][2] / to_rad - data[HEAD_BONE_QUAT] = [data["=head"][3], data["=head"][4], data["=head"][5], 1] - # print(data[HEAD_BONE_QUAT][2],min(data[EYE_BLINK_LEFT],data[EYE_BLINK_RIGHT])) - data[RIGHT_EYE_BONE_X] = data["rightEye"][0] / to_rad - data[RIGHT_EYE_BONE_Y] = data["rightEye"][1] / to_rad - data[RIGHT_EYE_BONE_Z] = data["rightEye"][2] / to_rad - data[LEFT_EYE_BONE_X] = data["leftEye"][0] / to_rad - data[LEFT_EYE_BONE_Y] = data["leftEye"][1] / to_rad - data[LEFT_EYE_BONE_Z] = data["leftEye"][2] / to_rad - - return data - - -if __name__ == '__main__': - client_process = ClientProcess() - client_process.daemon = True - client_process.start() - - while True: - pass \ No newline at end of file diff --git a/onnx_export_tha4.py b/tha4/onnx_export_tha4.py similarity index 100% rename from onnx_export_tha4.py rename to tha4/onnx_export_tha4.py diff --git a/onnx_export_tha4_student.py b/tha4/onnx_export_tha4_student.py similarity index 100% rename from onnx_export_tha4_student.py rename to tha4/onnx_export_tha4_student.py diff --git a/test_tha4_student.py b/tha4/test_tha4_student.py similarity index 100% rename from test_tha4_student.py rename to tha4/test_tha4_student.py diff --git a/tha4_adapter.py b/tha4/tha4_adapter.py similarity index 100% rename from tha4_adapter.py rename to tha4/tha4_adapter.py diff --git a/tha4_convert_onnx_to_trt.py b/tha4/tha4_convert_onnx_to_trt.py similarity index 100% rename from tha4_convert_onnx_to_trt.py rename to tha4/tha4_convert_onnx_to_trt.py diff --git a/tha4_core.py b/tha4/tha4_core.py similarity index 100% rename from tha4_core.py rename to tha4/tha4_core.py diff --git a/tha4_core_old.py b/tha4/tha4_core_old.py similarity index 100% rename from tha4_core_old.py rename to tha4/tha4_core_old.py diff --git a/tha4_student_convert_onnx_to_trt.py b/tha4/tha4_student_convert_onnx_to_trt.py similarity index 100% rename from tha4_student_convert_onnx_to_trt.py rename to tha4/tha4_student_convert_onnx_to_trt.py