Switch to PredictorModel from string
This commit is contained in:
@ -25,9 +25,9 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
private readonly Model _Model;
|
||||
private readonly string _ArgZero;
|
||||
private readonly Serilog.ILogger? _Log;
|
||||
private readonly Configuration _Configuration;
|
||||
private readonly ModelParameter _ModelParameter;
|
||||
private readonly PredictorModel _PredictorModel;
|
||||
private readonly Configuration _Configuration;
|
||||
private readonly JsonSerializerOptions _WriteIndentedJsonSerializerOptions;
|
||||
|
||||
protected double? _Α;
|
||||
@ -291,11 +291,11 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
D_Face? face = null;
|
||||
Rectangle rectangle;
|
||||
double[] rawEncoding;
|
||||
IEnumerable<FacePoint> facePoints;
|
||||
Shared.Models.FaceEncoding faceEncoding;
|
||||
FaceRecognitionDotNet.Image? knownImage;
|
||||
FaceRecognitionDotNet.Image? rotatedImage;
|
||||
Shared.Models.FaceEncoding faceEncoding;
|
||||
FaceRecognitionDotNet.FaceEncoding[] faceEncodings;
|
||||
IEnumerable<FacePoint> facePoints;
|
||||
IDictionary<FacePart, IEnumerable<FacePoint>>[] faceLandmarks;
|
||||
using Bitmap source = unknownImage.ToBitmap();
|
||||
padding = (int)((source.Width + source.Height) / 2 * .01);
|
||||
@ -303,7 +303,6 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
{
|
||||
for (int p = 0; p <= _Configuration.PaddingLoops.Value; p++)
|
||||
{
|
||||
//Location(double confidence, int bottom, int left, int right, int top)
|
||||
location = new(locations[i].Confidence,
|
||||
locations[i].Bottom + (padding * p),
|
||||
locations[i].Left - (padding * p),
|
||||
@ -320,9 +319,11 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
// source.Save(Path.Combine(_Configuration.RootDirectory, "source.jpg"));
|
||||
// preRotated.Save(Path.Combine(_Configuration.RootDirectory, $"{p} - preRotated.jpg"));
|
||||
using (knownImage = FaceRecognition.LoadImage(preRotated))
|
||||
if (knownImage is null)
|
||||
{
|
||||
if (knownImage is null || knownImage.IsDisposed)
|
||||
throw new Exception($"{nameof(knownImage)} is null");
|
||||
faceLandmarks = faceRecognition.FaceLandmark(knownImage, faceLocations: null, _PredictorModel, _Model).ToArray();
|
||||
faceLandmarks = faceRecognition.FaceLandmark(knownImage, faceLocations: null, _PredictorModel, _Model).ToArray();
|
||||
}
|
||||
if (faceLandmarks.Length == 0 && p < _Configuration.PaddingLoops.Value)
|
||||
continue;
|
||||
else if (faceLandmarks.Length != 1)
|
||||
@ -342,9 +343,11 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
{
|
||||
// rotated.Save(Path.Combine(_Configuration.RootDirectory, $"{p} - rotated.jpg"));
|
||||
using (rotatedImage = FaceRecognition.LoadImage(rotated))
|
||||
if (rotatedImage is null)
|
||||
{
|
||||
if (rotatedImage is null || rotatedImage.IsDisposed)
|
||||
throw new Exception($"{nameof(rotatedImage)} is null");
|
||||
faceEncodings = faceRecognition.FaceEncodings(rotatedImage, knownFaceLocation: null, _Configuration.NumJitters.Value, _PredictorModel, _Model).ToArray();
|
||||
faceEncodings = faceRecognition.FaceEncodings(rotatedImage, knownFaceLocation: null, _Configuration.NumJitters.Value, _PredictorModel, _Model).ToArray();
|
||||
}
|
||||
if (faceEncodings.Length == 0 && p < _Configuration.PaddingLoops.Value)
|
||||
continue;
|
||||
else if (faceEncodings.Length != 1)
|
||||
@ -520,7 +523,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
PropertyHolder propertyHolder;
|
||||
WindowsShortcut windowsShortcut;
|
||||
const string pattern = @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]";
|
||||
string dFacesContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, model.ToString(), predictorModel.ToString(), nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "(_)");
|
||||
string dFacesContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, model, predictorModel, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "(_)");
|
||||
for (int i = 0; i < filteredPropertyHolderCollection.Length; i++)
|
||||
{
|
||||
personKey = string.Empty;
|
||||
|
Reference in New Issue
Block a user