Skip to content

Commit 3f366d0

Browse files
committed
Release 1.218.2025
1 parent bf11a67 commit 3f366d0

22 files changed

Lines changed: 13026 additions & 13211 deletions
File renamed without changes.

Functions/GenXdev.AI.DeepStack/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Set-AIImageCollection -ImageDirectories @("~\Pictures")
6161
6262
# update
6363
Update-AllAIMetadata -ShowWindow
64-
Export-ImageDatabase
64+
Export-ImageIndex
6565
6666
Find-IndexedImage -HasNudity -HasExplicitContent -ShowInBrowser -InterActive
6767

Functions/GenXdev.AI.LMStudio/Get-LMStudioTextEmbedding.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ function Get-LMStudioTextEmbedding {
433433

434434
process {
435435

436-
$InputObject | ForEach-Object -ErrorAction SilentlyContinue {
436+
$InputObject | Microsoft.PowerShell.Core\ForEach-Object -ErrorAction SilentlyContinue {
437437
$text = "$PSItem";
438438
if ([string]::IsNullOrWhiteSpace($text)) { return }
439439

Functions/GenXdev.AI.Queries/Export-ImageDatabase.ps1 renamed to Functions/GenXdev.AI.Queries/Export-ImageIndex.ps1

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,17 @@ processes as if InputObject was not set. Allows appending search results to
174174
existing collections.
175175
176176
.EXAMPLE
177-
Export-ImageDatabase -DatabaseFilePath "C:\Custom\Path\images.db" `
177+
Export-ImageIndex -DatabaseFilePath "C:\Custom\Path\images.db" `
178178
-ImageDirectories @("C:\Photos", "D:\Images") -EmbedImages
179179
180180
.EXAMPLE
181181
indexcachedimages
182182
#>
183183
###############################################################################
184-
function Export-ImageDatabase {
184+
function Export-ImageIndex {
185185

186186
[CmdletBinding()]
187-
[Alias('indexcachedimages', 'Inititalize-ImageDatabase', 'Recreate-ImageIndex')]
187+
[Alias('indeximages')]
188188

189189
param(
190190
###############################################################################
@@ -548,13 +548,13 @@ function Export-ImageDatabase {
548548
# determine database file path if not provided
549549
$params = GenXdev.Helpers\Copy-IdenticalParamValues `
550550
-BoundParameters $PSBoundParameters `
551-
-FunctionName 'GenXdev.AI\Get-ImageDatabasePath' `
551+
-FunctionName 'GenXdev.AI\Get-ImageIndexPath' `
552552
-DefaultValues (
553553
Microsoft.PowerShell.Utility\Get-Variable -Scope Local `
554554
-ErrorAction SilentlyContinue
555555
)
556556

557-
$DatabaseFilePath = GenXdev.AI\Get-ImageDatabasePath @params -NeverRebuild
557+
$DatabaseFilePath = GenXdev.AI\Get-ImageIndexPath @params -NeverRebuild -NoFallback
558558

559559
# retrieve configured image directories if not provided
560560
$params = GenXdev.Helpers\Copy-IdenticalParamValues `
@@ -636,6 +636,9 @@ function Export-ImageDatabase {
636636
$DatabaseFilePath
637637
) -CreateDirectory -DeleteExistingFile -ErrorAction SilentlyContinue
638638

639+
# define backup file path for database
640+
$DatabaseBackupFilePath = "${DatabaseFilePath}.backup.db"
641+
639642
# check if the database file exists after expansion and handle backup
640643
if ([IO.File]::Exists($DatabaseFilePath)) {
641644

@@ -1680,13 +1683,13 @@ CREATE INDEX IF NOT EXISTS idx_images_scene_confidence_range ON Images(scene_con
16801683

16811684
$params = GenXdev.Helpers\Copy-IdenticalParamValues `
16821685
-BoundParameters $PSBoundParameters `
1683-
-FunctionName 'GenXdev.AI\Get-ImageDatabaseStats' `
1686+
-FunctionName 'GenXdev.AI\Get-ImageIndexStats' `
16841687
-DefaultValues (
16851688
Microsoft.PowerShell.Utility\Get-Variable -Scope Local `
16861689
-ErrorAction SilentlyContinue
16871690
)
16881691

1689-
GenXdev.AI\Get-ImageDatabaseStats @params |
1692+
GenXdev.AI\Get-ImageIndexStats @params |
16901693
Microsoft.PowerShell.Utility\Write-Output
16911694
}
16921695
}

Functions/GenXdev.AI.Queries/Find-Image.ps1

Lines changed: 26 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,6 @@ Find-Image -Scenes "beach" -MinConfidenceRatio 0.75 -ImageDirectories "C:\Photos
392392
Searches for beach scenes with confidence level of 75% or higher and filters people, scenes, and objects data by confidence.
393393
#>
394394
###############################################################################
395-
396-
397-
398395
function Find-Image {
399396

400397
[CmdletBinding()]
@@ -1147,7 +1144,13 @@ function Find-Image {
11471144
param($item)
11481145

11491146
# get full path of current image file being processed
1150-
$image = $PSItem.FullName
1147+
$image = $item
1148+
if ($image -is [IO.FileInfo]) { $image = $item.FullName }
1149+
# skip if image path is null or empty
1150+
if ([string]::IsNullOrEmpty($image)) {
1151+
Microsoft.PowerShell.Utility\Write-Warning "Skipping null or empty image path"
1152+
return
1153+
}
11511154

11521155
# output current image being processed for debugging purposes
11531156
Microsoft.PowerShell.Utility\Write-Verbose (
@@ -1335,7 +1338,7 @@ function Find-Image {
13351338
(($null -ne $MetaFocalLength) -and ($MetaFocalLength.Count -gt 0)) -or
13361339
(($null -ne $MetaDateTaken) -and ($MetaDateTaken.Count -gt 0)) -or
13371340
(($null -ne $GeoLocation) -and ($GeoLocation.Count -eq 2)) -or
1338-
($null -ne $MinConfidenceRatio)
1341+
($PSBoundParameters.ContainsKey('MinConfidenceRatio'))
13391342

13401343
# assume match if no search criteria specified (return all images with metadata)
13411344
# if we have search criteria, start with true and set to false if any criteria fails (AND logic)
@@ -1542,20 +1545,14 @@ function Find-Image {
15421545
}
15431546
}
15441547

1545-
# perform confidence filtering if minimum confidence ratio is specified
1546-
if ($null -ne $MinConfidenceRatio) {
1548+
# perform confidence filtering only if minimum confidence ratio is explicitly specified
1549+
if ($PSBoundParameters.ContainsKey('MinConfidenceRatio') -and $null -ne $MinConfidenceRatio) {
15471550
$confidenceMatch = $false # Start with false, set true if any confidence meets minimum threshold
15481551

15491552
# filter scenes by confidence - remove scenes below minimum threshold
15501553
if ($null -ne $scenesFound -and $null -ne $scenesFound.confidence) {
15511554
if ($scenesFound.confidence -ge $MinConfidenceRatio) {
15521555
$confidenceMatch = $true
1553-
1554-
# output scene confidence match for debugging purposes
1555-
Microsoft.PowerShell.Utility\Write-Verbose (
1556-
"Confidence filtering - Scene match: " +
1557-
"scene confidence $($scenesFound.confidence) >= " +
1558-
"minimum $MinConfidenceRatio for image $image")
15591556
} else {
15601557
# filter out the scene data by setting it to default
15611558
$scenesFound = @{
@@ -1564,11 +1561,6 @@ function Find-Image {
15641561
label = 'unknown'
15651562
confidence = 0.0
15661563
}
1567-
1568-
# output scene confidence rejection for debugging purposes
1569-
Microsoft.PowerShell.Utility\Write-Verbose (
1570-
"Confidence filtering - Scene filtered out: " +
1571-
"scene confidence below minimum $MinConfidenceRatio for image $image")
15721564
}
15731565
}
15741566

@@ -1579,17 +1571,6 @@ function Find-Image {
15791571
if ($null -ne $prediction.confidence -and $prediction.confidence -ge $MinConfidenceRatio) {
15801572
$filteredPredictions += $prediction
15811573
$confidenceMatch = $true
1582-
1583-
# output people confidence match for debugging purposes
1584-
Microsoft.PowerShell.Utility\Write-Verbose (
1585-
"Confidence filtering - People match: " +
1586-
"person '$($prediction.label)' confidence $($prediction.confidence) >= " +
1587-
"minimum $MinConfidenceRatio for image $image")
1588-
} else {
1589-
# output people confidence rejection for debugging purposes
1590-
Microsoft.PowerShell.Utility\Write-Verbose (
1591-
"Confidence filtering - Person filtered out: " +
1592-
"'$($prediction.label)' confidence below minimum $MinConfidenceRatio for image $image")
15931574
}
15941575
}
15951576
$peopleFound.predictions = $filteredPredictions
@@ -1615,17 +1596,6 @@ function Find-Image {
16151596
} else {
16161597
$filteredCounts[$obj.label] = 1
16171598
}
1618-
1619-
# output object confidence match for debugging purposes
1620-
Microsoft.PowerShell.Utility\Write-Verbose (
1621-
"Confidence filtering - Object match: " +
1622-
"object '$($obj.label)' confidence $($obj.confidence) >= " +
1623-
"minimum $MinConfidenceRatio for image $image")
1624-
} else {
1625-
# output object confidence rejection for debugging purposes
1626-
Microsoft.PowerShell.Utility\Write-Verbose (
1627-
"Confidence filtering - Object filtered out: " +
1628-
"'$($obj.label)' confidence below minimum $MinConfidenceRatio for image $image")
16291599
}
16301600
}
16311601

@@ -1636,7 +1606,7 @@ function Find-Image {
16361606

16371607
# if no confidence match was found and MinConfidenceRatio is specified, skip this image
16381608
if (-not $confidenceMatch) {
1639-
# output no confidence match for debugging purposes
1609+
# skip the image when confidence filtering is enabled but no data meets threshold
16401610
Microsoft.PowerShell.Utility\Write-Verbose (
16411611
"Confidence filtering - No confidence data meets minimum threshold " +
16421612
"$MinConfidenceRatio for image $image")
@@ -2042,8 +2012,8 @@ function Find-Image {
20422012
if ($null -ne $standardizedOutput.people -and
20432013
-not $standardizedOutput.people.PSObject.Properties['predictions']) {
20442014

2045-
# convert to PSCustomObject and add predictions array
2046-
$standardizedOutput.people = [PSCustomObject]@{
2015+
# convert to hashtable and add predictions array
2016+
$standardizedOutput.people = @{
20472017
count = $standardizedOutput.people.count
20482018
faces = $standardizedOutput.people.faces
20492019
predictions = @() # empty array for consistency
@@ -2054,8 +2024,8 @@ function Find-Image {
20542024
if ($null -ne $standardizedOutput.objects -and
20552025
-not $standardizedOutput.objects.PSObject.Properties['objects']) {
20562026

2057-
# convert to PSCustomObject and add objects array
2058-
$standardizedOutput.objects = [PSCustomObject]@{
2027+
# convert to hashtable and add objects array
2028+
$standardizedOutput.objects = @{
20592029
count = $standardizedOutput.objects.count
20602030
objects = if ($standardizedOutput.objects.objects) {
20612031
$standardizedOutput.objects.objects
@@ -2068,7 +2038,7 @@ function Find-Image {
20682038

20692039
# ensure scenes object has all required properties for consistency
20702040
if ($null -ne $standardizedOutput.scenes) {
2071-
$standardizedOutput.scenes = [PSCustomObject]@{
2041+
$standardizedOutput.scenes = @{
20722042
success = $standardizedOutput.scenes.success
20732043
scene = $standardizedOutput.scenes.scene
20742044
confidence = $standardizedOutput.scenes.confidence
@@ -2092,8 +2062,8 @@ function Find-Image {
20922062

20932063
# ensure description object has all required properties and consistent structure
20942064
if ($null -ne $standardizedOutput.description) {
2095-
# create standardized description object structure
2096-
$descObj = [PSCustomObject]@{
2065+
# create standardized description hashtable structure
2066+
$descObj = @{
20972067
has_explicit_content = if ($standardizedOutput.description.PSObject.Properties['has_explicit_content']) {
20982068
[bool]$standardizedOutput.description.has_explicit_content
20992069
} else {
@@ -2124,13 +2094,13 @@ function Find-Image {
21242094

21252095
# add description content if available
21262096
if ($standardizedOutput.description.PSObject.Properties['description']) {
2127-
$descObj | Microsoft.PowerShell.Utility\Add-Member -MemberType NoteProperty -Name 'description' -Value $standardizedOutput.description.description
2097+
$descObj['description'] = $standardizedOutput.description.description
21282098
}
21292099
if ($standardizedOutput.description.PSObject.Properties['short_description']) {
2130-
$descObj | Microsoft.PowerShell.Utility\Add-Member -MemberType NoteProperty -Name 'short_description' -Value $standardizedOutput.description.short_description
2100+
$descObj['short_description'] = $standardizedOutput.description.short_description
21312101
}
21322102
if ($standardizedOutput.description.PSObject.Properties['long_description']) {
2133-
$descObj | Microsoft.PowerShell.Utility\Add-Member -MemberType NoteProperty -Name 'long_description' -Value $standardizedOutput.description.long_description
2103+
$descObj['long_description'] = $standardizedOutput.description.long_description
21342104
}
21352105

21362106
$standardizedOutput.description = $descObj
@@ -2233,12 +2203,10 @@ function Find-Image {
22332203
$InputObject | Microsoft.PowerShell.Utility\Write-Output
22342204

22352205
# then clear InputObject and continue processing as if it wasn't set
2236-
$originalInputObject = $InputObject
22372206
$InputObject = $null
22382207

22392208
Microsoft.PowerShell.Utility\Write-Verbose (
2240-
"Append mode: Output ${originalInputObject.Count} objects, " +
2241-
"now processing search criteria"
2209+
"Append mode: Output input objects, now processing search criteria"
22422210
)
22432211
}
22442212

@@ -2397,7 +2365,8 @@ function Find-Image {
23972365
# output directly or add to results based on browser display setting
23982366
if (-not $ShowInBrowser) {
23992367

2400-
Microsoft.PowerShell.Utility\Write-Output $_
2368+
# Convert to formatted ImageSearchResult object
2369+
$_ #| GenXdev.Helpers\ConvertTo-ImageSearchResult
24012370
}
24022371
else {
24032372

@@ -2450,11 +2419,8 @@ function Find-Image {
24502419
# return results if passthru is requested for further processing
24512420
if ($PassThru) {
24522421

2453-
# output each result object to pipeline
2454-
$results | Microsoft.PowerShell.Core\ForEach-Object {
2455-
2456-
Microsoft.PowerShell.Utility\Write-Output $_
2457-
}
2422+
# output each result object to pipeline with formatting
2423+
$results | Microsoft.PowerShell.Core\ForEach-Object { $_ } # GenXdev.Helpers\ConvertTo-ImageSearchResult
24582424
}
24592425
}
24602426
}

0 commit comments

Comments
 (0)