You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel.ML/DNN/Models/YoloPrediction.cs

67 lines
1.8 KiB

2 years ago
using ZeroLevel.Services.Serialization;
namespace ZeroLevel.ML.DNN.Models
2 years ago
{
public class YoloPrediction
: IBinarySerializable
{
public int Class { get; set; }
public float Cx { get; set; }
public float Cy { get; set; }
public float W { get; set; }
public float H { get; set; }
public float Score { get; set; }
public string Label { get; set; } = string.Empty;
2 years ago
public float X { get { return Cx - W / 2.0f; } }
public float Y { get { return Cy - W / 2.0f; } }
public float Area { get { return W * H; } }
public string Description
{
get
{
return $"{Label} ({(int)(Score * 100)} %)";
}
}
public float this[int index]
{
get
{
switch (index)
{
case 0: return Cx;
case 1: return Cy;
case 2: return Cx + W;
case 3: return Cy + H;
}
return 0;
}
}
public void Serialize(IBinaryWriter writer)
2 years ago
{
writer.WriteInt32(Class);
writer.WriteFloat(Cx);
writer.WriteFloat(Cy);
writer.WriteFloat(W);
writer.WriteFloat(H);
writer.WriteFloat(Score);
writer.WriteString(Label);
2 years ago
}
public void Deserialize(IBinaryReader reader)
2 years ago
{
Class = reader.ReadInt32();
Cx = reader.ReadFloat();
Cy = reader.ReadFloat();
W = reader.ReadFloat();
H = reader.ReadFloat();
Score = reader.ReadFloat();
Label = reader.ReadString();
2 years ago
}
}
}

Powered by TurnKey Linux.