AI Pettorali

This commit is contained in:
MaddoScientisto 2026-05-09 17:27:05 +02:00
commit cb41c42bb5
11 changed files with 379 additions and 55 deletions

View file

@ -137,12 +137,17 @@ namespace ImageCatalog_2
}
}
private async Task RunAiExtractionCoreAsync(CancellationToken token, bool useDestination = false, bool recursive = false)
private async Task RunAiExtractionCoreAsync(CancellationToken token, bool useDestination = false, bool recursive = false, bool failOnInvalidPath = false)
{
var searchRoot = useDestination ? DestinationPath : SourcePath;
if (string.IsNullOrWhiteSpace(searchRoot) || !System.IO.Directory.Exists(searchRoot))
{
_logger.LogWarning("AI extraction path invalid: {Path}", searchRoot);
if (failOnInvalidPath)
{
throw new DirectoryNotFoundException($"AI extraction path invalid: {searchRoot}");
}
return;
}
@ -157,6 +162,8 @@ namespace ImageCatalog_2
{
SearchRoot = searchRoot,
Recursive = recursive,
ModelsFolderPath = ModelsFolderPath,
UseGpu = UseNumberAiGpu,
CsvOutputPath = CsvOutputPath
},
token,
@ -202,6 +209,12 @@ namespace ImageCatalog_2
set => _ai.CsvOutputPath = value;
}
public bool UseNumberAiGpu
{
get => _ai.UseNumberAiGpu;
set => _ai.UseNumberAiGpu = value;
}
public string FaceExecutablePath
{
get => _ai.FaceExecutablePath;
@ -1223,7 +1236,7 @@ namespace ImageCatalog_2
Debug.WriteLine("Yep c");
}
private async Task ProcessImages()
public async Task ProcessImages()
{
_logger.LogInformation("Avvio elaborazione...");
UiEnabled = false;
@ -1289,12 +1302,12 @@ namespace ImageCatalog_2
},
speed => { SpeedCounter = speed; }).ConfigureAwait(false);
// AI integration stub: if ExtractNumbers is enabled, simulate or invoke OCR processing
// AI integration: OCR runs over processed output so it matches the face AI input folder.
if (ExtractNumbers)
{
try
{
await RunAiExtractionCoreAsync(token);
await RunAiExtractionCoreAsync(token, useDestination: true, recursive: true);
}
catch (OperationCanceledException)
{
@ -1327,6 +1340,17 @@ namespace ImageCatalog_2
UiEnabled = true;
}
public async Task RunNumberAiAsync(CancellationToken token)
{
await RunAiExtractionCoreAsync(token, useDestination: true, recursive: true, failOnInvalidPath: true).ConfigureAwait(false);
}
public async Task RunFaceAiAsync(CancellationToken token)
{
using var registration = token.Register(() => _ = StopFaceEncoderAsync("Arresto face encoder richiesto dalla CLI.", waitForExit: true));
await RunFaceEncoderAsync().ConfigureAwait(false);
}
private async Task CancelOperation()
{
try