mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 19:56:31 +00:00
fix dataset explorer
This commit is contained in:
@@ -84,7 +84,7 @@ public partial class DatasetExplorer
|
||||
ExplorerEditor.CurrentAnnClass = (AnnotationClass)LvClasses.SelectedItem;
|
||||
await ReloadThumbnails();
|
||||
LoadClassDistribution();
|
||||
|
||||
|
||||
SizeChanged += async (_, _) => await SaveUserSettings();
|
||||
LocationChanged += async (_, _) => await SaveUserSettings();
|
||||
StateChanged += async (_, _) => await SaveUserSettings();
|
||||
@@ -273,7 +273,7 @@ public partial class DatasetExplorer
|
||||
var thumbnailDtos = new List<ThumbnailDto>();
|
||||
for (int i = 0; i < thumbnails.Length; i++)
|
||||
{
|
||||
var thumbnailDto = GetThumbnail(thumbnails[i]);
|
||||
var thumbnailDto = await GetThumbnail(thumbnails[i]);
|
||||
if (thumbnailDto != null)
|
||||
thumbnailDtos.Add(thumbnailDto);
|
||||
|
||||
@@ -289,12 +289,14 @@ public partial class DatasetExplorer
|
||||
LoadingAnnsBar.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private ThumbnailDto? GetThumbnail(string thumbnail)
|
||||
private async Task<ThumbnailDto?> GetThumbnail(string thumbnail)
|
||||
{
|
||||
try
|
||||
{
|
||||
var name = Path.GetFileNameWithoutExtension(thumbnail)[..^Config.THUMBNAIL_PREFIX.Length];
|
||||
var imagePath = Path.Combine(_config.ImagesDirectory, name);
|
||||
var labelPath = Path.Combine(_config.LabelsDirectory, $"{name}.txt");
|
||||
|
||||
foreach (var f in _config.ImageFormats)
|
||||
{
|
||||
var curName = $"{imagePath}.{f}";
|
||||
@@ -305,25 +307,21 @@ public partial class DatasetExplorer
|
||||
}
|
||||
}
|
||||
|
||||
var labelPath = Path.Combine(_config.LabelsDirectory, $"{name}.txt");
|
||||
|
||||
if (!_galleryManager.LabelsCache.TryGetValue(Path.GetFileName(imagePath), out var info))
|
||||
{
|
||||
if (File.Exists(labelPath))
|
||||
return null;
|
||||
|
||||
var imageExists = File.Exists(imagePath);
|
||||
if (!imageExists)
|
||||
if (!File.Exists(imagePath) || !File.Exists(labelPath))
|
||||
{
|
||||
File.Delete(thumbnail);
|
||||
_logger.LogError($"No label {labelPath} found ! Image {imagePath} not found, thumbnail {thumbnail} was removed");
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
File.Move(imagePath, Path.Combine(_config.UnknownImages, imagePath));
|
||||
_logger.LogError($"No label {labelPath} found! But Image {imagePath} exists! Image moved to {_config.UnknownImages} directory!");
|
||||
}
|
||||
return null;
|
||||
|
||||
var classes = (await YoloLabel.ReadFromFile(labelPath))
|
||||
.Select(x => x.ClassNumber)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
info = _galleryManager.AddToCache(imagePath, classes);
|
||||
}
|
||||
|
||||
if (!info.Classes.Contains(ExplorerEditor.CurrentAnnClass.Id) && ExplorerEditor.CurrentAnnClass.Id != -1)
|
||||
|
||||
Reference in New Issue
Block a user