fix inference UI and annotation saving

This commit is contained in:
Alex Bezdieniezhnykh
2025-01-30 12:33:24 +02:00
parent 62623b7123
commit e7afa96a0b
6 changed files with 47 additions and 163 deletions
@@ -106,6 +106,8 @@ public class AnnotationService : INotificationHandler<AnnotationsDeletedEvent>
{
a.Time = TimeSpan.FromMilliseconds(a.Milliseconds);
a.Name = a.OriginalMediaName.ToTimeName(a.Time);
foreach (var det in a.Detections)
det.AnnotationName = a.Name;
return await SaveAnnotationInner(DateTime.Now, a.OriginalMediaName, a.Time, ".jpg", a.Detections.ToList(),
a.Source, new MemoryStream(a.Image), a.CreatedRole, a.CreatedEmail, generateThumbnail: true, cancellationToken);
}
+3 -3
View File
@@ -14,12 +14,12 @@ namespace Azaion.Common.Services;
public interface IInferenceService
{
Task RunInference(string mediaPath, Func<AnnotationImage, CancellationToken, Task> processAnnotation, CancellationToken ct = default);
Task RunInference(string mediaPath, Func<AnnotationImage, Task> processAnnotation);
}
public class PythonInferenceService(ILogger<PythonInferenceService> logger, IOptions<AIRecognitionConfig> aiConfigOptions) : IInferenceService
{
public async Task RunInference(string mediaPath, Func<AnnotationImage, CancellationToken, Task> processAnnotation, CancellationToken ct = default)
public async Task RunInference(string mediaPath, Func<AnnotationImage, Task> processAnnotation)
{
using var dealer = new DealerSocket();
var clientId = Guid.NewGuid();
@@ -42,7 +42,7 @@ public class PythonInferenceService(ILogger<PythonInferenceService> logger, IOpt
continue;
}
await processAnnotation(annotationStream, ct);
await processAnnotation(annotationStream);
}
catch (Exception e)
{