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.NN/Architectures/FaceRecognition/Resnet27.cs

41 lines
1.1 KiB

using Microsoft.ML.OnnxRuntime.Tensors;
using SixLabors.ImageSharp;
using ZeroLevel.NN.Models;
namespace ZeroLevel.NN
{
public class Resnet27
: SSDNN, IEncoder
{
private const int INPUT_WIDTH = 128;
private const int INPUT_HEIGHT = 128;
public Resnet27(string modelPath)
: base(modelPath)
{
}
public int InputW => INPUT_WIDTH;
public int InputH => INPUT_HEIGHT;
public float[] Predict(Image image)
{
var input = MakeInput(image,
new ImagePreprocessorOptions(INPUT_WIDTH, INPUT_HEIGHT, PredictorChannelType.ChannelFirst)
.ApplyCorrection((c, px) => (px - 127.5f) / 128f)
.ApplyAxeInversion());
return Predict(input);
}
public float[] Predict(Tensor<float> input)
{
float[] embedding = null;
Extract(new Dictionary<string, Tensor<float>> { { "input.1", input } }, d =>
{
embedding = d.First().Value.ToArray();
});
Norm(embedding);
return embedding;
}
}
}

Powered by TurnKey Linux.