mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 09:46:30 +00:00
fix ui bugs, fix RefreshThumbnails method
This commit is contained in:
@@ -147,7 +147,7 @@ public class AnnotationService : INotificationHandler<AnnotationsDeletedEvent>
|
||||
: AnnotationStatus.Created;
|
||||
|
||||
await db.Detections.DeleteAsync(x => x.AnnotationName == fName, token: token);
|
||||
await db.BulkCopyAsync(detections, cancellationToken: token);
|
||||
|
||||
if (ann != null)
|
||||
{
|
||||
await db.Annotations
|
||||
@@ -177,6 +177,7 @@ public class AnnotationService : INotificationHandler<AnnotationsDeletedEvent>
|
||||
};
|
||||
await db.InsertAsync(ann, token: token);
|
||||
}
|
||||
await db.BulkCopyAsync(detections, cancellationToken: token);
|
||||
return ann;
|
||||
});
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public class GalleryService(
|
||||
await _updateLock.WaitAsync();
|
||||
var existingAnnotations = new ConcurrentDictionary<string, Annotation>(await dbFactory.Run(async db =>
|
||||
await db.Annotations.ToDictionaryAsync(x => x.Name)));
|
||||
var missedAnnotations = new ConcurrentBag<Annotation>();
|
||||
var missedAnnotations = new ConcurrentDictionary<string, Annotation>();
|
||||
try
|
||||
{
|
||||
var prefixLen = Constants.THUMBNAIL_PREFIX.Length;
|
||||
@@ -89,7 +89,7 @@ public class GalleryService(
|
||||
|
||||
await ParallelExt.ForEachAsync(files, async (file, cancellationToken) =>
|
||||
{
|
||||
var fName = Path.GetFileNameWithoutExtension(file.Name);
|
||||
var fName = file.Name.ToFName();
|
||||
try
|
||||
{
|
||||
var labelName = Path.Combine(_dirConfig.LabelsDirectory, $"{fName}.txt");
|
||||
@@ -136,7 +136,7 @@ public class GalleryService(
|
||||
{
|
||||
Time = time,
|
||||
OriginalMediaName = originalMediaName,
|
||||
Name = file.Name.ToFName(),
|
||||
Name = fName,
|
||||
ImageExtension = Path.GetExtension(file.Name),
|
||||
Detections = detections,
|
||||
CreatedDate = File.GetCreationTimeUtc(file.FullName),
|
||||
@@ -146,8 +146,15 @@ public class GalleryService(
|
||||
AnnotationStatus = AnnotationStatus.Validated
|
||||
};
|
||||
|
||||
//Remove duplicates
|
||||
if (!existingAnnotations.ContainsKey(fName))
|
||||
missedAnnotations.Add(annotation);
|
||||
{
|
||||
if (missedAnnotations.ContainsKey(fName))
|
||||
Console.WriteLine($"{fName} is already exists! Duplicate!");
|
||||
else
|
||||
missedAnnotations.TryAdd(fName, annotation);
|
||||
}
|
||||
|
||||
|
||||
if (!thumbnails.Contains(fName))
|
||||
await CreateThumbnail(annotation, cancellationToken);
|
||||
@@ -181,10 +188,20 @@ public class GalleryService(
|
||||
{
|
||||
MaxBatchSize = 50
|
||||
};
|
||||
|
||||
//Db could be updated during the long files scraping
|
||||
existingAnnotations = new ConcurrentDictionary<string, Annotation>(await dbFactory.Run(async db =>
|
||||
await db.Annotations.ToDictionaryAsync(x => x.Name)));
|
||||
var insertedDuplicates = missedAnnotations.Where(x => existingAnnotations.ContainsKey(x.Key)).ToList();
|
||||
var annotationsToInsert = missedAnnotations
|
||||
.Where(a => !existingAnnotations.ContainsKey(a.Key))
|
||||
.Select(x => x.Value)
|
||||
.ToList();
|
||||
|
||||
await dbFactory.Run(async db =>
|
||||
{
|
||||
await db.BulkCopyAsync(copyOptions, missedAnnotations);
|
||||
await db.BulkCopyAsync(copyOptions, missedAnnotations.SelectMany(x => x.Detections));
|
||||
await db.BulkCopyAsync(copyOptions, annotationsToInsert);
|
||||
await db.BulkCopyAsync(copyOptions, annotationsToInsert.SelectMany(x => x.Detections));
|
||||
});
|
||||
dbFactory.SaveToDisk();
|
||||
_updateLock.Release();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using Azaion.Common.DTO;
|
||||
using Azaion.Common.DTO.Queue;
|
||||
using Azaion.Common.Events;
|
||||
@@ -103,26 +104,28 @@ public class DatasetExplorerEventHandler(
|
||||
|
||||
public async Task Handle(AnnotationCreatedEvent notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var annotation = notification.Annotation;
|
||||
var selectedClass = datasetExplorer.LvClasses.CurrentClassNumber;
|
||||
|
||||
//TODO: For editing existing need to handle updates
|
||||
datasetExplorer.AddAnnotationToDict(annotation);
|
||||
if (annotation.Classes.Contains(selectedClass) || selectedClass == -1)
|
||||
datasetExplorer.Dispatcher.Invoke(async () =>
|
||||
{
|
||||
var annThumb = new AnnotationThumbnail(annotation);
|
||||
if (datasetExplorer.SelectedAnnotationDict.ContainsKey(annThumb.Annotation.Name))
|
||||
{
|
||||
datasetExplorer.SelectedAnnotationDict.Remove(annThumb.Annotation.Name);
|
||||
var ann = datasetExplorer.SelectedAnnotations.FirstOrDefault(x => x.Annotation.Name == annThumb.Annotation.Name);
|
||||
if (ann != null)
|
||||
datasetExplorer.SelectedAnnotations.Remove(ann);
|
||||
}
|
||||
var annotation = notification.Annotation;
|
||||
var selectedClass = datasetExplorer.LvClasses.CurrentClassNumber;
|
||||
|
||||
datasetExplorer.SelectedAnnotations.Insert(0, annThumb);
|
||||
datasetExplorer.SelectedAnnotationDict.Add(annThumb.Annotation.Name, annThumb);
|
||||
}
|
||||
await Task.CompletedTask;
|
||||
//TODO: For editing existing need to handle updates
|
||||
datasetExplorer.AddAnnotationToDict(annotation);
|
||||
if (annotation.Classes.Contains(selectedClass) || selectedClass == -1)
|
||||
{
|
||||
var annThumb = new AnnotationThumbnail(annotation);
|
||||
if (datasetExplorer.SelectedAnnotationDict.ContainsKey(annThumb.Annotation.Name))
|
||||
{
|
||||
datasetExplorer.SelectedAnnotationDict.Remove(annThumb.Annotation.Name);
|
||||
var ann = datasetExplorer.SelectedAnnotations.FirstOrDefault(x => x.Annotation.Name == annThumb.Annotation.Name);
|
||||
if (ann != null)
|
||||
datasetExplorer.SelectedAnnotations.Remove(ann);
|
||||
}
|
||||
|
||||
datasetExplorer.SelectedAnnotations.Insert(0, annThumb);
|
||||
datasetExplorer.SelectedAnnotationDict.Add(annThumb.Annotation.Name, annThumb);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public async Task Handle(AnnotationsDeletedEvent notification, CancellationToken cancellationToken)
|
||||
|
||||
@@ -173,7 +173,9 @@ public partial class App
|
||||
services.AddSingleton<IResourceLoader>(_resourceLoader);
|
||||
services.AddSingleton<IAuthProvider>(_authProvider);
|
||||
services.AddSingleton<IInferenceService, InferenceService>();
|
||||
|
||||
services.AddSingleton<IGpsMatcherService, GpsMatcherService>();
|
||||
services.AddSingleton<ISatelliteDownloader, SatelliteDownloader>();
|
||||
services.AddHttpClient();
|
||||
#endregion
|
||||
|
||||
services.AddSingleton<IConfigUpdater, ConfigUpdater>();
|
||||
|
||||
@@ -9,7 +9,19 @@ call upload-file %FILE1_TO_UPLOAD% %RESOURCES_FOLDER%
|
||||
set FILE2_TO_UPLOAD=%cd%\..\Azaion.Dataset\bin\%CONFIG%\net8.0-windows\Azaion.Dataset.dll
|
||||
call upload-file %FILE2_TO_UPLOAD% %RESOURCES_FOLDER%
|
||||
|
||||
set DESTINATION=%cd%\bin\Debug\net8.0-windows\gps-denied
|
||||
set SUITE_FOLDER=%cd%\bin\%CONFIG%\net8.0-windows\
|
||||
|
||||
rem Inference
|
||||
|
||||
set INFERENCE_PATH=%cd%\..\Azaion.Inference
|
||||
xcopy /E %INFERENCE_PATH%\dist\azaion-inference %SUITE_FOLDER%
|
||||
copy %INFERENCE_PATH%\venv\Lib\site-packages\tensorrt_libs\nvinfer_10.dll %SUITE_FOLDER%
|
||||
copy %INFERENCE_PATH%\venv\Lib\site-packages\tensorrt_libs\nvinfer_plugin_10.dll %SUITE_FOLDER%
|
||||
copy %INFERENCE_PATH%\venv\Lib\site-packages\tensorrt_libs\nvonnxparser_10.dll %SUITE_FOLDER%
|
||||
copy %INFERENCE_PATH%\config.yaml %SUITE_FOLDER%
|
||||
|
||||
rem Gps Denied
|
||||
set DESTINATION=%SUITE_FOLDER%\gps-denied
|
||||
set GPS_DENIED=%cd%\..\..\gps-denied\
|
||||
|
||||
rmdir %DESTINATION% /s /q
|
||||
|
||||
Reference in New Issue
Block a user