fix switcher between modes in DatasetExplorer.xaml

This commit is contained in:
Alex Bezdieniezhnykh
2025-03-02 21:32:31 +02:00
parent 227d01ba5e
commit d93da15528
15 changed files with 141 additions and 55 deletions
+8 -6
View File
@@ -22,7 +22,7 @@ public partial class DatasetExplorer
private readonly AnnotationConfig _annotationConfig;
private readonly DirectoriesConfig _directoriesConfig;
private readonly Dictionary<int, List<Annotation>> _annotationsDict;
private readonly Dictionary<int, Dictionary<string, Annotation>> _annotationsDict;
private readonly CancellationTokenSource _cts = new();
public List<DetectionClass> AllDetectionClasses { get; set; }
@@ -61,7 +61,7 @@ public partial class DatasetExplorer
var photoModes = Enum.GetValues(typeof(PhotoMode)).Cast<PhotoMode>().ToList();
_annotationsDict = _annotationConfig.DetectionClasses.SelectMany(cls => photoModes.Select(mode => (int)mode + cls.Id))
.ToDictionary(x => x, _ => new List<Annotation>());
.ToDictionary(x => x, _ => new Dictionary<string, Annotation>());
_annotationsDict.Add(-1, []);
AnnotationsClasses = annotationConfig.Value.DetectionClasses;
@@ -141,8 +141,8 @@ public partial class DatasetExplorer
public void AddAnnotationToDict(Annotation annotation)
{
foreach (var c in annotation.Classes)
_annotationsDict[c].Add(annotation);
_annotationsDict[-1].Add(annotation);
_annotationsDict[c][annotation.Name] = annotation;
_annotationsDict[-1][annotation.Name] = annotation;
}
private async Task LoadClassDistribution()
@@ -277,9 +277,11 @@ public partial class DatasetExplorer
private async Task ReloadThumbnails()
{
SelectedAnnotations.Clear();
foreach (var ann in _annotationsDict[ExplorerEditor.CurrentAnnClass.Id])
SelectedAnnotationDict.Clear();
var annotations = _annotationsDict[ExplorerEditor.CurrentAnnClass.YoloId];
foreach (var ann in annotations.OrderByDescending(x => x.Value.CreatedDate))
{
var annThumb = new AnnotationThumbnail(ann);
var annThumb = new AnnotationThumbnail(ann.Value);
SelectedAnnotations.Add(annThumb);
SelectedAnnotationDict.Add(annThumb.Annotation.Name, annThumb);
}