mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 17:46:36 +00:00
fix dataset explorer
This commit is contained in:
@@ -148,20 +148,17 @@ public class GalleryManager : IGalleryManager
|
||||
_logger.LogInformation($"No labels found for image {imgName}! Image deleted!");
|
||||
return null;
|
||||
}
|
||||
|
||||
var labels = (await YoloLabel.ReadFromFile(labelName, cancellationToken))
|
||||
.Select(x => new CanvasLabel(x, size, size))
|
||||
.ToList();
|
||||
var classes = labels.Select(x => x.ClassNumber).Distinct().ToList();
|
||||
|
||||
AddToCache(imgPath, classes);
|
||||
|
||||
var thumbWhRatio = width / (float)height;
|
||||
var border = _config.ThumbnailConfig.Border;
|
||||
|
||||
var classes = labels.Select(x => x.ClassNumber).Distinct().ToList();
|
||||
LabelsCache.TryAdd(imgName, new LabelInfo
|
||||
{
|
||||
Classes = classes,
|
||||
ImageDateTime = File.GetCreationTimeUtc(imgPath)
|
||||
});
|
||||
|
||||
var frameX = 0.0;
|
||||
var frameY = 0.0;
|
||||
var frameHeight = size.Height;
|
||||
@@ -223,6 +220,20 @@ public class GalleryManager : IGalleryManager
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public LabelInfo AddToCache(string imgPath, List<int> classes)
|
||||
{
|
||||
var labelInfo = new LabelInfo
|
||||
{
|
||||
Classes = classes,
|
||||
ImageDateTime = File.GetCreationTimeUtc(imgPath)
|
||||
};
|
||||
LabelsCache.TryAdd(Path.GetFileName(imgPath), labelInfo);
|
||||
|
||||
//Save to file only each 2 seconds
|
||||
_ = ThrottleExt.Throttle(async () => await SaveLabelsCache(), TimeSpan.FromSeconds(2));
|
||||
return labelInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public interface IGalleryManager
|
||||
@@ -230,6 +241,7 @@ public interface IGalleryManager
|
||||
event ThumbnailsUpdatedEventHandler ThumbnailsUpdate;
|
||||
double ThumbnailsPercentage { get; set; }
|
||||
Task SaveLabelsCache();
|
||||
LabelInfo AddToCache(string imgPath, List<int> classes);
|
||||
ConcurrentDictionary<string, LabelInfo> LabelsCache { get; set; }
|
||||
Task<ThumbnailDto?> CreateThumbnail(string imgPath, CancellationToken cancellationToken = default);
|
||||
Task RefreshThumbnails();
|
||||
|
||||
Reference in New Issue
Block a user