1- # ##############################################################################
1+ # ##############################################################################
22<#
33. SYNOPSIS
44Recognizes faces in an uploaded image by comparing to known faces using
@@ -205,7 +205,7 @@ function Get-ImageDetectedFaces {
205205 - ErrorAction SilentlyContinue)
206206
207207 # initialize deepstack docker container if needed
208- $null = EnsureDeepStack @ensureParams
208+ $null = GenXdev.AI\ EnsureDeepStack @ensureParams
209209 } else {
210210 Microsoft.PowerShell.Utility\Write-Verbose `
211211 ' Skipping Docker initialization as requested' }
@@ -232,6 +232,16 @@ function Get-ImageDetectedFaces {
232232
233233 Microsoft.PowerShell.Utility\Write-Verbose " Sending request to: $uri "
234234
235+ # Validate image file exists before processing
236+ if (-not [System.IO.File ]::Exists($imagePath )) {
237+ Microsoft.PowerShell.Utility\Write-Warning " Image file not found: $imagePath "
238+ return @ {
239+ success = $false
240+ error = " No valid image file found"
241+ duration = 0
242+ } | Microsoft.PowerShell.Utility\ConvertTo-Json
243+ }
244+
235245 # create form data for DeepStack API (it expects multipart form
236246 # data, not JSON)
237247 $form = @ {
@@ -268,18 +278,27 @@ function Get-ImageDetectedFaces {
268278 Microsoft.PowerShell.Utility\Write-Output $response
269279 }
270280 catch [System.Net.WebException ] {
271- Microsoft.PowerShell.Utility\Write-Error `
281+ Microsoft.PowerShell.Utility\Write-Warning `
272282 (' Network error while contacting DeepStack face recognition ' +
273283 " service: $_ " )
274284 }
275285 catch [System.TimeoutException ] {
276- Microsoft.PowerShell.Utility\Write-Error `
286+ Microsoft.PowerShell.Utility\Write-Warning `
277287 (' Timeout while waiting for DeepStack face recognition ' +
278288 " response: $_ " )
279289 }
280290 catch {
281- Microsoft.PowerShell.Utility\Write-Error `
282- " Failed to recognize faces: $_ "
291+ # Check if this is a file access issue vs actual processing failure
292+ if ($_.Exception.Message -like " *Could not find item*" -or
293+ $_.Exception.Message -like " *No valid image file found*" ) {
294+
295+ Microsoft.PowerShell.Utility\Write-Verbose `
296+ " Face detection skipped - file not accessible: $imagePath "
297+ }
298+ else {
299+ Microsoft.PowerShell.Utility\Write-Warning `
300+ " Face detection failed for $imagePath `: $ ( $_.Exception.Message ) "
301+ }
283302 }
284303 }
285304
0 commit comments