mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 08:56:30 +00:00
queue + local sqlite WIP
This commit is contained in:
@@ -158,19 +158,25 @@ public class YoloLabel : Label
|
||||
public static async Task<List<YoloLabel>> ReadFromFile(string filename, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var str = await File.ReadAllTextAsync(filename, cancellationToken);
|
||||
|
||||
return str.Split('\n')
|
||||
.Select(Parse)
|
||||
.Where(ann => ann != null)
|
||||
.ToList()!;
|
||||
return Deserialize(str);
|
||||
}
|
||||
|
||||
public static async Task WriteToFile(IEnumerable<YoloLabel> labels, string filename, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var labelsStr = string.Join(Environment.NewLine, labels.Select(x => x.ToString()));
|
||||
var labelsStr = Serialize(labels);
|
||||
await File.WriteAllTextAsync(filename, labelsStr, cancellationToken);
|
||||
}
|
||||
|
||||
public static string Serialize(IEnumerable<YoloLabel> labels) =>
|
||||
string.Join(Environment.NewLine, labels.Select(x => x.ToString()));
|
||||
|
||||
public static List<YoloLabel> Deserialize(string str) =>
|
||||
str.Split('\n')
|
||||
.Select(Parse)
|
||||
.Where(ann => ann != null)
|
||||
.ToList()!;
|
||||
|
||||
|
||||
public override string ToString() => $"{ClassNumber} {CenterX:F5} {CenterY:F5} {Width:F5} {Height:F5}".Replace(',', '.');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user