Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Webreaper committed Mar 8, 2024
1 parent e6ab331 commit 76a1fab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
24 changes: 15 additions & 9 deletions Damselfly.Core/Services/ImageRecognitionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,14 @@ public async Task<bool> NeedsAIMigration()
using var scope = _scopeFactory.CreateScope();
using var db = scope.ServiceProvider.GetService<ImageContext>();

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;
}

Expand All @@ -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));
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion Damselfly.Web.Client/wwwroot/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const CACHE_VERSION='4.1.0-20240308175037'
const CACHE_VERSION='4.1.0-20240308215734'

0 comments on commit 76a1fab

Please sign in to comment.