feat: Refactor multicore selection and enhance output handling in face encoder script
All checks were successful
Publish FaceAI Container / publish (push) Successful in 3m53s
All checks were successful
Publish FaceAI Container / publish (push) Successful in 3m53s
This commit is contained in:
parent
77e48b8139
commit
0926c52a00
1 changed files with 39 additions and 6 deletions
|
|
@ -7,10 +7,10 @@ Write-Host " 3 = 1/2 dei core (predefinito)"
|
|||
Write-Host " 4 = 3/4 dei core"
|
||||
Write-Host " 5 = n-2 core"
|
||||
Write-Host ""
|
||||
$input = Read-Host "Inserisci il livello (1-5) oppure premi Invio per usare il predefinito (3)"
|
||||
$multicoreChoice = Read-Host "Inserisci il livello (1-5) oppure premi Invio per usare il predefinito (3)"
|
||||
|
||||
if ($input -match '^[1-5]$') {
|
||||
$multicore = [int]$input
|
||||
if ($multicoreChoice -match '^[1-5]$') {
|
||||
$multicore = [int]$multicoreChoice
|
||||
} else {
|
||||
$multicore = -1
|
||||
}
|
||||
|
|
@ -94,13 +94,33 @@ if (-not $inputPath) {
|
|||
exit 0
|
||||
}
|
||||
|
||||
$inputFolder = Get-Item -LiteralPath $inputPath -ErrorAction Stop
|
||||
$raceName = $inputFolder.Name
|
||||
$safeRaceName = ($raceName -replace '[<>:"/\\|?*]', ' ').Trim()
|
||||
$safeRaceName = $safeRaceName -replace '\s+', '_'
|
||||
if (-not $safeRaceName) {
|
||||
$safeRaceName = 'race'
|
||||
}
|
||||
|
||||
$timestamp = Get-Date -Format 'yyyyMMdd_HHmmss'
|
||||
$encoderDir = Join-Path $PSScriptRoot "face_encoder_cpu"
|
||||
$outputDir = Join-Path $encoderDir "output"
|
||||
$outputFile = Join-Path $outputDir ("face_encodings_{0}_{1}.pkl" -f $timestamp, $safeRaceName)
|
||||
$logFile = Join-Path $outputDir ("encoder_log_{0}_{1}.txt" -f $timestamp, $safeRaceName)
|
||||
|
||||
New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
|
||||
|
||||
# --- Build argument list ---
|
||||
$encoderExe = Join-Path $PSScriptRoot "face_encoder_cpu\face_encoder_cpu.exe"
|
||||
$encoderExe = Join-Path $encoderDir "face_encoder_cpu.exe"
|
||||
|
||||
$encoderArgs = [System.Collections.Generic.List[string]]::new()
|
||||
$encoderArgs.Add("-i")
|
||||
$encoderArgs.Add($inputPath)
|
||||
$encoderArgs.Add($inputFolder.FullName)
|
||||
$encoderArgs.Add("-r")
|
||||
$encoderArgs.Add("-o")
|
||||
$encoderArgs.Add($outputFile)
|
||||
$encoderArgs.Add("-l")
|
||||
$encoderArgs.Add($logFile)
|
||||
|
||||
if ($multicore -ge 0) {
|
||||
$encoderArgs.Add("-m")
|
||||
|
|
@ -108,9 +128,22 @@ if ($multicore -ge 0) {
|
|||
}
|
||||
|
||||
# --- Run encoder ---
|
||||
Write-Host "Input folder : $inputPath"
|
||||
Write-Host "Input folder : $($inputFolder.FullName)"
|
||||
Write-Host "Race name : $raceName"
|
||||
Write-Host "Multicore : $(if ($multicore -ge 0) { $multicore } else { 'default (3)' })"
|
||||
Write-Host "Output file : $outputFile"
|
||||
Write-Host "Log file : $logFile"
|
||||
Write-Host "Command : $encoderExe $encoderArgs"
|
||||
Write-Host ""
|
||||
|
||||
& $encoderExe @encoderArgs
|
||||
|
||||
$encoderExitCode = $LASTEXITCODE
|
||||
|
||||
if ($encoderExitCode -eq 0 -and (Test-Path -LiteralPath $outputFile)) {
|
||||
Start-Process explorer.exe "/select,`"$outputFile`""
|
||||
} elseif ($encoderExitCode -eq 0) {
|
||||
Write-Warning "Encoding completed, but the expected output file was not found: $outputFile"
|
||||
}
|
||||
|
||||
exit $encoderExitCode
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue