Files
silver_pose/init.ps1
T

41 lines
1.3 KiB
PowerShell
Raw Normal View History

2026-07-20 22:05:55 +08:00
#!/usr/bin/env pwsh
# Silver Pose 的 Windows 统一启动与验证入口。
2026-07-21 09:45:42 +08:00
# V1 的 requirements.txt 是显式安装清单;本脚本只检查已安装依赖,避免修改当前环境。
2026-07-20 22:05:55 +08:00
$ErrorActionPreference = "Stop"
Set-Location -Path $PSScriptRoot
$InstallCmd = 'python -c "import cv2, numpy, ultralytics, PyQt5; print(''required Python packages available'')"'
$VerifyCmd = "python -m compileall -q demo"
2026-07-21 09:45:42 +08:00
$V1TestCmd = "python -m pytest v1/tests -v"
$StartCmd = "python -m v1.app"
2026-07-20 22:05:55 +08:00
function Invoke-Checked {
param([string]$Label, [string]$Command)
Write-Host "==> $Label"
Invoke-Expression $Command
if ($LASTEXITCODE -ne 0) {
throw "$Label failed with exit code $LASTEXITCODE"
}
}
Write-Host "==> 当前目录: $($PWD.Path)"
Invoke-Checked -Label "检查 Silver Pose Python 依赖" -Command $InstallCmd
if (Test-Path -LiteralPath "demo") {
Invoke-Checked -Label "运行 demo 基线验证" -Command $VerifyCmd
} else {
Write-Host "==> 发布包未包含 demo/,跳过旧基线编译"
}
2026-07-21 09:45:42 +08:00
Invoke-Checked -Label "运行 V1 单元测试" -Command $V1TestCmd
2026-07-20 22:05:55 +08:00
Write-Host "==> 图形界面启动命令"
Write-Host " $StartCmd"
if ($env:RUN_START_COMMAND -eq "1") {
Write-Host "==> 启动应用"
Invoke-Expression $StartCmd
} else {
Write-Host "设置 RUN_START_COMMAND=1 后,init.ps1 会启动 GUI。"
}