更新推理工具,优化界面和功能,支持批量推理和分页显示结果 #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: cpp-cmake-ci | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - main | |
| tags: | |
| - "v*" | |
| pull_request: | |
| branches: | |
| - master | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| env: | |
| APP_NAME: YOLOClassifier | |
| BUILD_TYPE: Release | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| build: | |
| name: ${{ matrix.name }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: Windows / Qt 5.12.12 | |
| os: windows-2022 | |
| qt_host: windows | |
| qt_arch: win64_msvc2017_64 | |
| vcpkg_triplet: x64-windows | |
| artifact_name: YOLOClassifier-windows-x64 | |
| - name: Linux / Qt 5.12.12 | |
| os: ubuntu-22.04 | |
| qt_host: linux | |
| qt_arch: gcc_64 | |
| vcpkg_triplet: x64-linux | |
| artifact_name: YOLOClassifier-linux-x64 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Install Linux system packages | |
| if: runner.os == 'Linux' | |
| shell: bash | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| ninja-build \ | |
| autoconf \ | |
| autoconf-archive \ | |
| automake \ | |
| libtool \ | |
| pkg-config | |
| - name: Setup MSVC | |
| if: runner.os == 'Windows' | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: x64 | |
| - name: Install Qt 5.12.12 | |
| uses: jurplel/install-qt-action@v4 | |
| with: | |
| version: 5.12.12 | |
| host: ${{ matrix.qt_host }} | |
| target: desktop | |
| arch: ${{ matrix.qt_arch }} | |
| cache: true | |
| install-deps: true | |
| - name: Bootstrap vcpkg on Windows | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| git clone https://github.com/microsoft/vcpkg.git "$env:RUNNER_TEMP\vcpkg" | |
| & "$env:RUNNER_TEMP\vcpkg\bootstrap-vcpkg.bat" -disableMetrics | |
| "VCPKG_ROOT=$env:RUNNER_TEMP\vcpkg" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| - name: Bootstrap vcpkg on Linux | |
| if: runner.os == 'Linux' | |
| shell: bash | |
| run: | | |
| git clone https://github.com/microsoft/vcpkg.git "$RUNNER_TEMP/vcpkg" | |
| "$RUNNER_TEMP/vcpkg/bootstrap-vcpkg.sh" -disableMetrics | |
| echo "VCPKG_ROOT=$RUNNER_TEMP/vcpkg" >> "$GITHUB_ENV" | |
| - name: Restore vcpkg cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ${{ runner.temp }}/vcpkg/downloads | |
| ${{ runner.temp }}/vcpkg/packages | |
| ${{ runner.temp }}/vcpkg/installed | |
| key: vcpkg-${{ runner.os }}-${{ matrix.vcpkg_triplet }}-${{ hashFiles('.github/workflows/cpp-cmake-ci.yml', 'CMakeLists.txt') }} | |
| restore-keys: | | |
| vcpkg-${{ runner.os }}-${{ matrix.vcpkg_triplet }}- | |
| - name: Install C++ dependencies on Windows | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| & "$env:VCPKG_ROOT\vcpkg.exe" install ` | |
| "onnxruntime:${{ matrix.vcpkg_triplet }}" ` | |
| "opencv4[core,jpeg,png,webp]:${{ matrix.vcpkg_triplet }}" | |
| - name: Install C++ dependencies on Linux | |
| if: runner.os == 'Linux' | |
| shell: bash | |
| run: | | |
| "$VCPKG_ROOT/vcpkg" install \ | |
| "onnxruntime:${{ matrix.vcpkg_triplet }}" \ | |
| "opencv4[core,jpeg,png,webp]:${{ matrix.vcpkg_triplet }}" | |
| - name: Configure on Windows | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| cmake -S . -B build -G Ninja ` | |
| "-DCMAKE_BUILD_TYPE=${env:BUILD_TYPE}" ` | |
| "-DCMAKE_TOOLCHAIN_FILE=$env:VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake" ` | |
| "-DVCPKG_TARGET_TRIPLET=${{ matrix.vcpkg_triplet }}" ` | |
| "-DQt5_DIR=$env:Qt5_DIR" | |
| - name: Configure on Linux | |
| if: runner.os == 'Linux' | |
| shell: bash | |
| run: | | |
| cmake -S . -B build -G Ninja \ | |
| -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \ | |
| -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \ | |
| -DVCPKG_TARGET_TRIPLET="${{ matrix.vcpkg_triplet }}" \ | |
| -DQt5_DIR="${Qt5_DIR}" | |
| - name: Build on Windows | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: cmake --build build --config $env:BUILD_TYPE --parallel | |
| - name: Build on Linux | |
| if: runner.os == 'Linux' | |
| shell: bash | |
| run: cmake --build build --config "${BUILD_TYPE}" --parallel | |
| - name: Package Windows bundle | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| env: | |
| BUILD_DIR: ${{ github.workspace }}\build | |
| DIST_DIR: ${{ github.workspace }}\dist | |
| VCPKG_TRIPLET: ${{ matrix.vcpkg_triplet }} | |
| run: .\scripts\package-windows.ps1 | |
| - name: Package Linux artifact | |
| if: runner.os == 'Linux' | |
| shell: bash | |
| run: | | |
| package_dir="dist/${{ matrix.artifact_name }}" | |
| mkdir -p "${package_dir}" | |
| cp "build/bin/${APP_NAME}" "${package_dir}/" | |
| cp README.md "${package_dir}/" | |
| if [ -f "models/cat_vs_dog/best.onnx" ]; then | |
| mkdir -p "${package_dir}/models/cat_vs_dog" | |
| cp "models/cat_vs_dog/best.onnx" "${package_dir}/models/cat_vs_dog/" | |
| fi | |
| tar -C dist -czf "dist/${{ matrix.artifact_name }}.tar.gz" "${{ matrix.artifact_name }}" | |
| - name: Upload Windows artifact | |
| if: runner.os == 'Windows' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ matrix.artifact_name }} | |
| path: dist/${{ matrix.artifact_name }}.zip | |
| if-no-files-found: error | |
| - name: Upload Linux artifact | |
| if: runner.os == 'Linux' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ matrix.artifact_name }} | |
| path: dist/${{ matrix.artifact_name }}.tar.gz | |
| if-no-files-found: error | |
| - name: Publish GitHub Release | |
| if: runner.os == 'Windows' && github.ref_type == 'tag' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: dist/${{ matrix.artifact_name }}.zip | |
| generate_release_notes: true |