From d66e78a4f7d91f7264cab1d6652539470ee363b3 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 22 Apr 2025 19:30:45 +0800 Subject: [PATCH] ci test --- .github/workflows/build-windows-cuda-11.8.yml | 98 +++++++++++++++++++ backend/config.py | 3 + backend/tools/makedist.py | 49 ++++++++++ requirements.txt | 10 +- 4 files changed, 155 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/build-windows-cuda-11.8.yml create mode 100644 backend/tools/makedist.py diff --git a/.github/workflows/build-windows-cuda-11.8.yml b/.github/workflows/build-windows-cuda-11.8.yml new file mode 100644 index 0000000..583ea46 --- /dev/null +++ b/.github/workflows/build-windows-cuda-11.8.yml @@ -0,0 +1,98 @@ +name: Build Windows CUDA 11.8 + +on: + push: + branches: + - '**' + workflow_dispatch: + inputs: + ssh: + description: 'SSH connection to Actions' + required: false + default: false + + +jobs: + build: + runs-on: windows-2019 + steps: + - uses: actions/checkout@v4 + - name: 读取 VERSION + id: version + run: | + VERSION=$(sed -n 's/^VERSION = "\(.*\)"/\1/p' backend/config.py) + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + shell: bash + # - name: 检查 tag 是否已存在 + # run: | + # TAG_NAME="${VERSION}" + # if git ls-remote --tags origin | grep -q "refs/tags/$TAG_NAME"; then + # echo "Tag $TAG_NAME 已存在,发布中止" + # exit 1 + # fi + # shell: bash + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: 'pip' # caching pip dependencies + - run: pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/ + - run: pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu118 + - run: pip install -r requirements.txt + - run: pip freeze > requirements.txt + - run: pip install QPT==1.0b8 setuptools + - name: 获取 site-packages 路径 + shell: bash + run: | + SITE_PACKAGES=$(python -c "import site, os; print(os.path.join(site.getsitepackages()[0], 'Lib', 'site-packages'))") + SITE_PACKAGES_UNIX=$(cygpath -u "$SITE_PACKAGES") + echo "site-packages路径: $SITE_PACKAGES" + echo "site-packages UNIX路径: $SITE_PACKAGES_UNIX" + echo "SITE_PACKAGES_UNIX=$SITE_PACKAGES_UNIX" >> $GITHUB_ENV + echo "SITE_PACKAGES=$SITE_PACKAGES" >> $GITHUB_ENV + - name: 修复QPT内部错误 + run: sed -i '98c\ try:\n dep = pkg.requires()\n except TypeError:\n continue' ${SITE_PACKAGES_UNIX}/qpt/kernel/qpackage.py + shell: bash + - name: Start SSH via tmate + if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh') + uses: mxschmitt/action-tmate@v3 + - run: | + python backend/tools/makedist.py && \ + mv ../vsr_out ./vsr_out && \ + git checkout requirements.txt && \ + pip download -d ./vsr_out/Debug/opt/packages/ paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/ && \ + pip download -d ./vsr_out/Debug/opt/packages/ -r requirements.txt && \ + cp -rfv ./vsr_out/Debug/opt/packages/* ./vsr_out/Release/opt/packages/ && \ + rm -fv ./vsr_out/*/opt/packages/numpy-2* && \ + rm -fv ./vsr_out/*/opt/packages/paddlepaddle-* && \ + rm -fv ./vsr_out/*/opt/PaddlePaddlePackage/001-* + env: + QPT_Action: "True" + shell: bash + - name: 上传 Debug 文件夹到 Artifacts + uses: actions/upload-artifact@v4 + with: + name: vsr-v${{ env.VERSION }}-windows-nvidia-cuda-11.8-debug + path: vsr_out/Debug/ + - name: 上传 Release 文件夹到 Artifacts + uses: actions/upload-artifact@v4 + with: + name: vsr-v${{ env.VERSION }}-windows-nvidia-cuda-11.8-release + path: vsr_out/Release/ + - name: 打包 Release 文件夹 + run: | + cd vsr_out/Release + 7z a -t7z -mx=9 -m0=LZMA2 -ms=on -mfb=64 -md=32m -mmt=on -v1888m vsr-v${{ env.VERSION }}-windows-nvidia-cuda-11.8.7z * && \ + # 检测是否只有一个分卷 + if [ -f vsr-v${{ env.VERSION }}-windows-nvidia-cuda-11.8.7z.001 ] && [ ! -f vsr-v${{ env.VERSION }}-windows-nvidia-cuda-11.8.7z.002 ]; then \ + mv vsr-v${{ env.VERSION }}-windows-nvidia-cuda-11.8.7z.001 vsr-v${{ env.VERSION }}-windows-nvidia-cuda-11.8.7z; fi + shell: bash + - name: Release + uses: softprops/action-gh-release@v1 + with: + prerelease: true + tag_name: ${{ env.VERSION }} + target_commitish: ${{ github.sha }} + name: 硬字幕提取器 ${{ env.VERSION }} + files: | + vsr_out/Release/vsr-v${{ env.VERSION }}-windows-nvidia-cuda-11.8.7z* \ No newline at end of file diff --git a/backend/config.py b/backend/config.py index f366f8c..82c041e 100644 --- a/backend/config.py +++ b/backend/config.py @@ -8,6 +8,9 @@ import platform import stat from fsplit.filesplit import Filesplit import paddle + +# 项目版本号 +VERSION = "1.1.1" # ×××××××××××××××××××× [不要改] start ×××××××××××××××××××× paddle.disable_signal_handler() logging.disable(logging.DEBUG) # 关闭DEBUG日志的打印 diff --git a/backend/tools/makedist.py b/backend/tools/makedist.py new file mode 100644 index 0000000..afe4fd3 --- /dev/null +++ b/backend/tools/makedist.py @@ -0,0 +1,49 @@ +import argparse +import os +from qpt.executor import CreateExecutableModule as CEM +from qpt.modules.cuda import CopyCUDAPackage +from qpt.smart_opt import set_default_pip_source +from qpt.kernel.qinterpreter import PYPI_PIP_SOURCE + + +def main(): + WORK_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + LAUNCH_PATH = os.path.join(WORK_DIR, 'gui.py') + SAVE_PATH = os.path.join(os.path.dirname(WORK_DIR), 'vsr_out') + ICON_PATH = os.path.join(WORK_DIR, "design", "vsr.ico") + + # 解析命令行参数 + parser = argparse.ArgumentParser(description="打包程序") + parser.add_argument( + "--cuda", + nargs="?", # 可选参数值 + const="10.2", # 如果只写 --cuda,默认值是 10.2 + default=None, # 不写 --cuda,则为 None + help="是否包含CUDA模块,可指定版本,如 --cuda 或 --cuda=11.8" + ) + + args = parser.parse_args() + + sub_modules = [] + + if args.cuda: + sub_modules.append(CopyCUDAPackage(cuda_version=args.cuda)) + + if os.getenv("QPT_Action") == "True": + set_default_pip_source(PYPI_PIP_SOURCE) + + module = CEM( + work_dir=WORK_DIR, + launcher_py_path=LAUNCH_PATH, + save_path=SAVE_PATH, + icon=ICON_PATH, + hidden_terminal=False, + requirements_file="./requirements.txt", + sub_modules=sub_modules, + ) + + module.make() + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index f578821..659670c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,21 +1,21 @@ albumentations==0.5.2 filesplit==3.0.2 opencv-python==4.8.1.78 -scikit-image==0.17.2 +scikit-image==0.25.2 imgaug==0.4.0 kornia==0.5.0 pyclipper==1.3.0.post5 -lmdb==1.4.1 +lmdb==1.6.2 PyYAML==6.0.1 omegaconf==2.1.2 tqdm==4.66.1 PySimpleGUI-4-foss==4.60.4.1 easydict==1.9 -scikit-learn==0.24.2 -pandas==2.0.3 +scikit-learn==1.6.1 +pandas==2.2.3 webdataset==0.2.57 pytorch-lightning==1.2.9 -numpy==1.23.1 +numpy==1.26.4 protobuf==3.20.0 av==11.0.0 einops==0.7.0