Archived
Reworked distance info algo
This commit is contained in:
@@ -39,7 +39,55 @@ public class ReportGenerator : IDisposable
|
||||
{
|
||||
Document.AppendHeading(2, title);
|
||||
|
||||
// todo show best/worst images per processor
|
||||
var processors = new Dictionary<string, ICollection<ImageStats>>();
|
||||
foreach (var image in Images)
|
||||
{
|
||||
foreach (var processor in image.Processors)
|
||||
{
|
||||
if (processors.TryGetValue(processor.Name, out var images))
|
||||
{
|
||||
images.Add(image);
|
||||
}
|
||||
else
|
||||
{
|
||||
processors.Add(processor.Name, new List<ImageStats> { image });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var (processor, images) in processors)
|
||||
{
|
||||
var ordered = images
|
||||
.Select(i => (Stats: i, Distance: i
|
||||
.Processors
|
||||
.Where(p => p.Name.Equals(processor))
|
||||
.Select(p => p.Distance)
|
||||
.Average()
|
||||
))
|
||||
.OrderBy(i => i.Distance)
|
||||
.ToArray();
|
||||
|
||||
Document
|
||||
.AppendHeading(3, processor)
|
||||
.AppendTable(2, table =>
|
||||
{
|
||||
table.AppendHeader(new[] { "Image", "Preview", "Distance" });
|
||||
|
||||
foreach (var (stats, distance) in ordered)
|
||||
{
|
||||
var imgPath = Path.Combine("results", $"{processor}.00.{stats.ImageName}.png");
|
||||
|
||||
table.AppendRow(new[]
|
||||
{
|
||||
$"<a href=\"#{stats.ImageName}\">{stats.ImageName}</a>",
|
||||
Document.FormatImage(imgPath, new Bounds(0, 150)),
|
||||
distance.ToString("F2")
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -75,10 +123,15 @@ public class ReportGenerator : IDisposable
|
||||
{
|
||||
var imgPath = Path.Combine("results", $"{processor.Name}.00.{stat.ImageName}.png");
|
||||
|
||||
string summarizedCer = string.Empty;
|
||||
summarizedCer = processor.Words
|
||||
.Average(s => s.Distance)
|
||||
.ToString("F2");
|
||||
|
||||
table.AppendRow(processor.Words
|
||||
.Select(s => s.ToString() ?? string.Empty)
|
||||
.Prepend(Document.FormatImage(imgPath, new Bounds(0, 150)))
|
||||
.Prepend(processor.Words.Average(s => s.Distance).ToString("F2"))
|
||||
.Prepend(summarizedCer)
|
||||
.Prepend($"{processor.Distance * 100:F1}%")
|
||||
.Prepend($"{processor.ProcessingTime * 1000:F1}ms")
|
||||
.Prepend(processor.Name)
|
||||
|
||||
Reference in New Issue
Block a user