119 lines
5.3 KiB
PowerShell
119 lines
5.3 KiB
PowerShell
[CmdletBinding()]
|
|
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$PackageRoot,
|
|
|
|
[string]$RuntimeRoot = 'D:\NDC_MISSIONCORE\runtime\experiments\e46j',
|
|
|
|
[string]$SourceVideo = 'D:\NDC_MISSIONCORE\runtime\experiments\e46e\inputs\right-cadd1696ff000904eb78633a0a8418104b8024f178b91f3421789021ccb160e8.mp4',
|
|
|
|
[string]$ValidFovMask = 'D:\NDC_MISSIONCORE\runtime\inputs\e2\valid-fov-mask-b4dd8ddf2b87c1d520ee8a0868c4fea062d7c14d1bae73ccabd3abe1f3acbac2\mask.png',
|
|
|
|
[int]$MaxFrames = 0,
|
|
|
|
[switch]$NoOverlay,
|
|
|
|
[string]$RunPrefix = 'full'
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
$ProgressPreference = 'SilentlyContinue'
|
|
|
|
function Get-Sha256([string]$Path) {
|
|
return (Get-FileHash -LiteralPath $Path -Algorithm SHA256).Hash.ToLowerInvariant()
|
|
}
|
|
|
|
$package = (Resolve-Path -LiteralPath $PackageRoot).Path
|
|
$source = (Resolve-Path -LiteralPath $SourceVideo).Path
|
|
$mask = (Resolve-Path -LiteralPath $ValidFovMask).Path
|
|
$profile = Join-Path $package 'e46j_raw_fisheye_yolox_profile.json'
|
|
$runner = Join-Path $package 'run_e46j_raw_fisheye_yolox.py'
|
|
if (-not (Test-Path -LiteralPath $profile -PathType Leaf) -or
|
|
-not (Test-Path -LiteralPath $runner -PathType Leaf)) {
|
|
throw 'E46J package is incomplete.'
|
|
}
|
|
if ((Get-Sha256 $source) -ne 'cadd1696ff000904eb78633a0a8418104b8024f178b91f3421789021ccb160e8') {
|
|
throw 'E46J source stream identity changed.'
|
|
}
|
|
|
|
$runsRoot = Join-Path $RuntimeRoot 'runs'
|
|
New-Item -ItemType Directory -Force -Path $runsRoot | Out-Null
|
|
$runId = "$RunPrefix-$((Get-Date).ToUniversalTime().ToString('yyyyMMddTHHmmssfffZ'))"
|
|
$image = 'nvcr.io/nvidia/tritonserver:26.06-py3@sha256:58df7489c3f2276f9591d500a012dee03e23d35543ce3c390b4c001e6bf90794'
|
|
$command = "python3 /workspace/package/run_e46j_raw_fisheye_yolox.py --input /workspace/input/right.mp4 --mask /workspace/valid-fov/mask.png --profile /workspace/package/e46j_raw_fisheye_yolox_profile.json --triton-url http://127.0.0.1:8000 --output /workspace/runs/$runId"
|
|
if ($MaxFrames -gt 0) {
|
|
$command += " --max-frames $MaxFrames"
|
|
}
|
|
if (-not $NoOverlay) {
|
|
$command += ' --overlay'
|
|
}
|
|
|
|
$dockerArguments = @(
|
|
'run', '--rm', '--name', "ndc-mission-core-e46j-$runId",
|
|
'--network', 'container:ndc-mission-core-triton',
|
|
'--gpus', 'all',
|
|
'--cap-drop', 'ALL',
|
|
'--security-opt', 'no-new-privileges',
|
|
'--shm-size', '1g',
|
|
'--label', 'com.nodedc.product=mission-core',
|
|
'--label', 'com.nodedc.stack=perception',
|
|
'--label', 'com.nodedc.role=e46j-raw-fisheye-realtime-gate',
|
|
'--label', 'com.nodedc.managed-by=mission-core-worker',
|
|
'--mount', "type=bind,src=$source,dst=/workspace/input/right.mp4,readonly",
|
|
'--mount', "type=bind,src=$mask,dst=/workspace/valid-fov/mask.png,readonly",
|
|
'--mount', "type=bind,src=$package,dst=/workspace/package,readonly",
|
|
'--mount', "type=bind,src=$runsRoot,dst=/workspace/runs",
|
|
'--mount', 'type=bind,src=D:\NDC_MISSIONCORE\runtime\derived\perception-p0-env-v1,dst=/opt/env,readonly',
|
|
'--mount', 'type=bind,src=D:\NDC_MISSIONCORE\runtime\derived\perception-e15-media-pyav180-lz445-v1,dst=/opt/media,readonly',
|
|
'--mount', 'type=bind,src=D:\NDC_MISSIONCORE\runtime\derived\perception-e3-opencv413092-v1,dst=/environment,readonly',
|
|
'-e', 'PYTHONPATH=/opt/env:/opt/media:/environment/packages',
|
|
'--entrypoint', '/bin/bash',
|
|
$image, '-lc', $command
|
|
)
|
|
|
|
& docker @dockerArguments
|
|
$runnerExitCode = $LASTEXITCODE
|
|
if ($runnerExitCode -ne 0 -and $runnerExitCode -ne 2) {
|
|
throw "E46J runner crashed with exit code $runnerExitCode"
|
|
}
|
|
$result = Join-Path $runsRoot $runId
|
|
$runtimePath = Join-Path $result 'runtime.json'
|
|
if (-not $NoOverlay) {
|
|
$intermediate = Join-Path $result 'raw-fisheye-yolox-overlay-intermediate.mp4'
|
|
$overlay = Join-Path $result 'raw-fisheye-yolox-overlay.mp4'
|
|
if (-not (Test-Path -LiteralPath $intermediate -PathType Leaf)) {
|
|
throw 'E46J intermediate overlay is missing.'
|
|
}
|
|
& ffmpeg.exe -hide_banner -loglevel error -y -i $intermediate `
|
|
-c:v libx264 -preset veryfast -crf 20 -r 4489000/448723 `
|
|
-movflags +faststart -an $overlay
|
|
if ($LASTEXITCODE -ne 0 -or
|
|
-not (Test-Path -LiteralPath $overlay -PathType Leaf) -or
|
|
(Get-Item -LiteralPath $overlay).Length -eq 0) {
|
|
throw 'E46J final H.264 overlay transcode failed.'
|
|
}
|
|
$runtime = Get-Content -LiteralPath $runtimePath -Raw | ConvertFrom-Json
|
|
$runtime.artifacts.PSObject.Properties.Remove('overlay_intermediate')
|
|
$runtime.artifacts | Add-Member -NotePropertyName overlay -NotePropertyValue ([pscustomobject]@{
|
|
file = 'raw-fisheye-yolox-overlay.mp4'
|
|
byte_length = (Get-Item -LiteralPath $overlay).Length
|
|
sha256 = Get-Sha256 $overlay
|
|
codec = 'H.264'
|
|
frame_rate = 10.003944527024467
|
|
})
|
|
$runtime | Add-Member -NotePropertyName visual_export -NotePropertyValue ([pscustomobject]@{
|
|
provider = ((& ffmpeg.exe -version | Select-Object -First 1).Trim())
|
|
source = 'MPEG-4 Part 2 intermediate produced by OpenCV VideoWriter'
|
|
output = 'H.264 MP4 with faststart'
|
|
excluded_from_core_latency = $true
|
|
})
|
|
$runtime | ConvertTo-Json -Depth 20 | Set-Content -LiteralPath $runtimePath -Encoding UTF8
|
|
Remove-Item -LiteralPath $intermediate -Force
|
|
}
|
|
Write-Output "E46J_RUN_ID=$runId"
|
|
Write-Output "E46J_RESULT_ROOT=$result"
|
|
Get-Content -LiteralPath $runtimePath -Raw
|
|
if ($runnerExitCode -eq 2) {
|
|
exit 2
|
|
}
|