Skip to content

Commit

Permalink
Primary constructors....
Browse files Browse the repository at this point in the history
  • Loading branch information
Webreaper committed Mar 7, 2024
1 parent 02238f7 commit 7afbaa3
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 59 deletions.
49 changes: 7 additions & 42 deletions Damselfly.Core/Services/ImageRecognitionService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
Expand All @@ -23,50 +22,16 @@

namespace Damselfly.Core.Services;

public class ImageRecognitionService : IPeopleService, IProcessJobFactory, IRescanProvider
public class ImageRecognitionService(IServiceScopeFactory _scopeFactory,
IStatusService _statusService, ObjectDetector _objectDetector,
MetaDataService _metdataService, FaceONNXService _faceOnnxService,
ThumbnailService _thumbService, ConfigService _configService,
ImageClassifier _imageClassifier, ImageCache _imageCache,
WorkService _workService, ExifService _exifService) : IPeopleService, IProcessJobFactory, IRescanProvider
{
private readonly ConfigService _configService;
private readonly FaceONNXService _faceOnnxService;
private readonly ExifService _exifService;
private readonly ImageCache _imageCache;
private readonly ImageClassifier _imageClassifier;
private readonly ImageProcessService _imageProcessor;
private readonly MetaDataService _metdataService;
private readonly ObjectDetector _objectDetector;

// WASM: This should be a MemoryCache
private readonly IDictionary<string, Person> _peopleCache = new ConcurrentDictionary<string, Person>();
private readonly IServiceScopeFactory _scopeFactory;
private readonly IStatusService _statusService;
private readonly ThumbnailService _thumbService;
private readonly WorkService _workService;

public ImageRecognitionService(IServiceScopeFactory scopeFactory,
IStatusService statusService, ObjectDetector objectDetector,
MetaDataService metadataService, FaceONNXService faceOnnxService,
ThumbnailService thumbs, ConfigService configService,
ImageClassifier imageClassifier, ImageCache imageCache,
WorkService workService, ExifService exifService,
ImageProcessService imageProcessor)
{
_scopeFactory = scopeFactory;
_thumbService = thumbs;
_statusService = statusService;
_objectDetector = objectDetector;
_metdataService = metadataService;
_faceOnnxService = faceOnnxService;
_configService = configService;
_imageClassifier = imageClassifier;
_imageProcessor = imageProcessor;
_imageCache = imageCache;
_workService = workService;
_exifService = exifService;
}

public ImageRecognitionService()
{
}


public static bool EnableImageRecognition { get; set; } = true;

public async Task<List<Person>> GetAllPeople()
Expand Down
14 changes: 1 addition & 13 deletions Damselfly.ML.FaceONNX/FaceONNXService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand All @@ -8,29 +7,18 @@
using Damselfly.Shared.Utils;
using FaceEmbeddingsClassification;
using FaceONNX;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.ML.OnnxRuntime;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;

namespace Damselfly.ML.FaceONNX;

public class FaceONNXService : IDisposable
public class FaceONNXService( ILogger<FaceONNXService> _logger): IDisposable
{
private readonly ILogger<FaceONNXService> _logger;
private readonly IServiceScopeFactory _scopeFactory;

private FaceDetector _faceDetector;
private FaceLandmarksExtractor _faceLandmarksExtractor;
private FaceEmbedder _faceEmbedder;
private readonly Embeddings _embeddings = new();

public FaceONNXService(IServiceScopeFactory scopeFactory, ILogger<FaceONNXService> logger )
{
_scopeFactory = scopeFactory;
_logger = logger;
}

public void Dispose()
{
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-20240307094413'
const CACHE_VERSION='4.1.0-20240307145827'
3 changes: 2 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
<TargetFramework>net8.0</TargetFramework>
<NoWarn>CS8603;CS8604;CS8618;IL2121</NoWarn>
</PropertyGroup>
<LangVersion>latest</LangVersion>
</PropertyGroup>
</Project>
1 change: 0 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<PackageVersion Include="Emgu.CV.runtime.ubuntu.20.04-x64" Version="4.5.1.4349" />
<PackageVersion Include="Emgu.CV.runtime.windows" Version="4.5.1.4349" />
<PackageVersion Include="FaceONNX" Version="3.0.1.3" />
<PackageVersion Include="FaceONNX.Addons.Gpu" Version="3.0.1.3" />
<PackageVersion Include="FluentValidation" Version="11.9.0" />
<PackageVersion Include="font-awesome" Version="4.7.0" />
<PackageVersion Include="Humanizer" Version="2.14.1" />
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE_IMAGE=webreaper/damselfly-base:1.9.1
ARG BASE_IMAGE=webreaper/damselfly-base:1.7.1

FROM $BASE_IMAGE as final

Expand Down

0 comments on commit 7afbaa3

Please sign in to comment.