From 76a1fabe23e94d34668bdfbff4bef7793d883545 Mon Sep 17 00:00:00 2001 From: Mark Otway Date: Fri, 8 Mar 2024 21:57:50 +0000 Subject: [PATCH] Fixes --- .../Services/ImageRecognitionService.cs | 24 ++++++++++++------- Damselfly.Web.Client/wwwroot/version.js | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Damselfly.Core/Services/ImageRecognitionService.cs b/Damselfly.Core/Services/ImageRecognitionService.cs index eed5606e..60fbe58d 100644 --- a/Damselfly.Core/Services/ImageRecognitionService.cs +++ b/Damselfly.Core/Services/ImageRecognitionService.cs @@ -657,9 +657,14 @@ public async Task NeedsAIMigration() using var scope = _scopeFactory.CreateScope(); using var db = scope.ServiceProvider.GetService(); + var deprecatedTypes = new[] + { + ImageObject.RecognitionType.Emgu, ImageObject.RecognitionType.Accord, ImageObject.RecognitionType.Azure + }; + // If we have any faces that were recognised by EMGU, Accord, or Azure, we need to rescan them - var needsMigration = await db.ImageObjects.AnyAsync( x => x.Type == "Face" && - x.RecogntionSource != ImageObject.RecognitionType.FaceONNX); + var needsMigration = await db.ImageObjects.AnyAsync( x => x.Type == "Face" && + deprecatedTypes.Contains( x.RecogntionSource)); return needsMigration; } @@ -680,8 +685,6 @@ public async Task ExecuteAIMigration( AIMigrationRequest req ) // Find all the images with imageObjects of type face, and set their AILastUpdated to null imagesUpdated = await db.ImageMetaData - .Include( x => x.Image) - .ThenInclude(x => x.ImageObjects) .Where( x => x.Image.ImageObjects.Any( io => io.Type == "Face")) .ExecuteUpdateAsync(x => x.SetProperty( p => p.AILastUpdated, v => null)); @@ -698,14 +701,17 @@ public async Task ExecuteAIMigration( AIMigrationRequest req ) _statusService.UpdateStatus("AI Migration: deleting all people from DB..."); - // Now, delete all existing face imageObjects - await db.ImageObjects.Where( x => x.Type == "Face" ) - .ExecuteDeleteAsync(); - // Delete all existing people var peopleDeleted = await db.People.ExecuteDeleteAsync(); - var msg = $"Deleted {peopleDeleted} people, and updated {imagesUpdated} images for AI scanning."; + _statusService.UpdateStatus("AI Migration: obsolete Image Objects DB..."); + + // Now, delete all existing face imageObjects + int deletedObjects = await db.ImageObjects.Where( x => x.Type == "Face" + && x.RecogntionSource != ImageObject.RecognitionType.FaceONNX) + .ExecuteDeleteAsync(); + + var msg = $"Deleted {peopleDeleted} people & {deletedObjects} objects, and updated {imagesUpdated} images for AI scanning."; _statusService.UpdateStatus(msg); _logger.LogInformation(msg); diff --git a/Damselfly.Web.Client/wwwroot/version.js b/Damselfly.Web.Client/wwwroot/version.js index 03b8b7bc..ac7d9f27 100644 --- a/Damselfly.Web.Client/wwwroot/version.js +++ b/Damselfly.Web.Client/wwwroot/version.js @@ -1 +1 @@ -const CACHE_VERSION='4.1.0-20240308175037' +const CACHE_VERSION='4.1.0-20240308215734'