Skip to content

Commit 2936cbd

Browse files
committed
Release 1.202.2025
1 parent 6a72895 commit 2936cbd

179 files changed

Lines changed: 39600 additions & 17400 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Functions/GenXdev.AI.DeepStack/Compare-ImageFaces.ps1

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
###############################################################################
1+
###############################################################################
22
<#
33
.SYNOPSIS
44
Compares faces in two different images and returns their similarity using
@@ -72,109 +72,110 @@ DeepStack API Documentation: POST /v1/vision/face/match endpoint for face
7272
comparison.
7373
Example: curl -X POST -F "image1=@person1.jpg" -F "image2=@person2.jpg"
7474
http://localhost:5000/v1/vision/face/match
75-
###############################################################################>
75+
#>
7676
function Compare-ImageFaces {
7777

7878
[CmdletBinding()]
7979
[OutputType([System.Collections.Hashtable])]
8080
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', '')]
81-
[Alias("comparefaces")]
81+
[Alias('comparefaces')]
8282

8383
param(
8484
###############################################################################
8585
[Parameter(
8686
Position = 0,
8787
Mandatory = $true,
88-
HelpMessage = "The local path to the first image file to compare"
88+
HelpMessage = 'The local path to the first image file to compare'
8989
)]
9090
[ValidateNotNullOrEmpty()]
9191
[string] $ImagePath1,
9292
###############################################################################
9393
[Parameter(
9494
Position = 1,
9595
Mandatory = $true,
96-
HelpMessage = "The local path to the second image file to compare"
96+
HelpMessage = 'The local path to the second image file to compare'
9797
)]
9898
[ValidateNotNullOrEmpty()]
9999
[string] $ImagePath2,
100100
###############################################################################
101101
[Parameter(
102102
Position = 2,
103103
Mandatory = $false,
104-
HelpMessage = "The name for the Docker container"
104+
HelpMessage = 'The name for the Docker container'
105105
)]
106106
[ValidateNotNullOrEmpty()]
107-
[string] $ContainerName = "deepstack_face_recognition",
107+
[string] $ContainerName = 'deepstack_face_recognition',
108108
###############################################################################
109109
[Parameter(
110110
Position = 3,
111111
Mandatory = $false,
112-
HelpMessage = ("The name for the Docker volume for persistent " +
113-
"storage")
112+
HelpMessage = ('The name for the Docker volume for persistent ' +
113+
'storage')
114114
)]
115115
[ValidateNotNullOrEmpty()]
116-
[string] $VolumeName = "deepstack_face_data",
116+
[string] $VolumeName = 'deepstack_face_data',
117117
###############################################################################
118118
[Parameter(
119119
Position = 4,
120120
Mandatory = $false,
121-
HelpMessage = "The port number for the DeepStack service"
121+
HelpMessage = 'The port number for the DeepStack service'
122122
)]
123123
[ValidateRange(1, 65535)]
124124
[int] $ServicePort = 5000,
125125
###############################################################################
126126
[Parameter(
127127
Position = 5,
128128
Mandatory = $false,
129-
HelpMessage = ("Maximum time in seconds to wait for service " +
130-
"health check")
129+
HelpMessage = ('Maximum time in seconds to wait for service ' +
130+
'health check')
131131
)]
132132
[ValidateRange(10, 300)]
133133
[int] $HealthCheckTimeout = 60,
134134
###############################################################################
135135
[Parameter(
136136
Position = 6,
137137
Mandatory = $false,
138-
HelpMessage = ("Interval in seconds between health check " +
139-
"attempts")
138+
HelpMessage = ('Interval in seconds between health check ' +
139+
'attempts')
140140
)]
141141
[ValidateRange(1, 10)]
142142
[int] $HealthCheckInterval = 3,
143143
###############################################################################
144144
[Parameter(
145145
Position = 7,
146146
Mandatory = $false,
147-
HelpMessage = "Custom Docker image name to use"
147+
HelpMessage = 'Custom Docker image name to use'
148148
)]
149149
[ValidateNotNullOrEmpty()]
150150
[string] $ImageName,
151151
###############################################################################
152152
[Parameter(
153153
Mandatory = $false,
154-
HelpMessage = ("Skip Docker initialization (used when already " +
155-
"called by parent function)")
154+
HelpMessage = ('Skip Docker initialization (used when already ' +
155+
'called by parent function)')
156156
)]
157157
[switch] $NoDockerInitialize,
158158
###############################################################################
159159
[Parameter(
160160
Mandatory = $false,
161-
HelpMessage = ("Force rebuild of Docker container and remove " +
162-
"existing data")
161+
HelpMessage = ('Force rebuild of Docker container and remove ' +
162+
'existing data')
163163
)]
164-
[Alias("ForceRebuild")]
164+
[Alias('ForceRebuild')]
165165
[switch] $Force,
166166
###############################################################################
167167
[Parameter(
168168
Mandatory = $false,
169-
HelpMessage = ("Use GPU-accelerated version (requires NVIDIA " +
170-
"GPU)")
169+
HelpMessage = ('Use GPU-accelerated version (requires NVIDIA ' +
170+
'GPU)')
171171
)]
172172
[switch] $UseGPU,
173173
###################################################################
174174
[Parameter(
175175
Mandatory = $false,
176-
HelpMessage = "Show Docker Desktop window during initialization"
176+
HelpMessage = 'Show Docker Desktop window during initialization'
177177
)]
178+
[Alias('sw')]
178179
[switch]$ShowWindow
179180
###################################################################
180181

@@ -193,7 +194,7 @@ function Compare-ImageFaces {
193194
if (-not $NoDockerInitialize) {
194195

195196
Microsoft.PowerShell.Utility\Write-Verbose `
196-
("Ensuring DeepStack face match service is available")
197+
('Ensuring DeepStack face match service is available')
197198

198199
# copy parameter values for the ensuredeepstack function call
199200
$ensureParams = GenXdev.Helpers\Copy-IdenticalParamValues `
@@ -204,12 +205,12 @@ function Compare-ImageFaces {
204205
-ErrorAction SilentlyContinue)
205206

206207
# initialize deepstack docker container if needed
207-
$null = GenXdev.AI\EnsureDeepStack @ensureParams
208+
$null = EnsureDeepStack @ensureParams
208209
}
209210
else {
210211

211212
Microsoft.PowerShell.Utility\Write-Verbose `
212-
"Skipping Docker initialization as requested"
213+
'Skipping Docker initialization as requested'
213214
} Microsoft.PowerShell.Utility\Write-Verbose `
214215
"Using DeepStack face match API at: $script:ApiBaseUrl"
215216

@@ -240,7 +241,7 @@ function Compare-ImageFaces {
240241
[Parameter(
241242
Position = 0,
242243
Mandatory = $true,
243-
HelpMessage = "The raw response data from DeepStack API"
244+
HelpMessage = 'The raw response data from DeepStack API'
244245
)]
245246
$MatchData
246247
###################################################################
@@ -256,12 +257,12 @@ function Compare-ImageFaces {
256257
if (-not $MatchData -or -not $MatchData.success) {
257258

258259
Microsoft.PowerShell.Utility\Write-Verbose `
259-
"No successful face match data received"
260+
'No successful face match data received'
260261

261262
return @{
262-
success = $false
263+
success = $false
263264
similarity = 0.0
264-
message = "Face match failed"
265+
message = 'Face match failed'
265266
}
266267
}
267268

@@ -279,9 +280,9 @@ function Compare-ImageFaces {
279280

280281
# return formatted result object with all relevant metrics
281282
return @{
282-
success = $true
283-
similarity = $similarity
284-
confidence = $similarity
283+
success = $true
284+
similarity = $similarity
285+
confidence = $similarity
285286
match_percentage = [math]::Round($similarity * 100, 2)
286287
}
287288
}
@@ -322,7 +323,7 @@ function Compare-ImageFaces {
322323

323324
# send the request to the deepstack face match api
324325
Microsoft.PowerShell.Utility\Write-Verbose `
325-
"Sending image data to DeepStack face match API"
326+
'Sending image data to DeepStack face match API'
326327

327328
$response = Microsoft.PowerShell.Utility\Invoke-RestMethod `
328329
-Uri $uri `
@@ -332,8 +333,8 @@ function Compare-ImageFaces {
332333
-ErrorAction Stop
333334

334335
Microsoft.PowerShell.Utility\Write-Verbose `
335-
("API Response: " +
336-
"$($response | `
336+
('API Response: ' +
337+
"$($response | `
337338
Microsoft.PowerShell.Utility\ConvertTo-Json -Depth 3)")
338339

339340
# process the response from deepstack using the helper function
@@ -349,19 +350,18 @@ function Compare-ImageFaces {
349350
catch [System.TimeoutException] {
350351

351352
Microsoft.PowerShell.Utility\Write-Error `
352-
("Timeout during face comparison between $imagePath1 and " +
353-
"$imagePath2")
353+
("Timeout during face comparison between $imagePath1 and " +
354+
"$imagePath2")
354355
}
355356
catch {
356357

357358
Microsoft.PowerShell.Utility\Write-Error `
358-
("Failed to compare faces between $imagePath1 and " +
359-
"$imagePath2`: $_")
359+
("Failed to compare faces between $imagePath1 and " +
360+
"$imagePath2`: $_")
360361
}
361362
}
362363

363364
end {
364365

365366
}
366367
}
367-
###############################################################################

0 commit comments

Comments
 (0)