Ready to test
This commit is contained in:
@ -8,6 +8,7 @@ using View_by_Distance.Instance.Models;
|
||||
using View_by_Distance.Metadata.Models;
|
||||
using View_by_Distance.Property.Models;
|
||||
using View_by_Distance.Resize.Models;
|
||||
using View_by_Distance.Shared.Models;
|
||||
using View_by_Distance.Shared.Models.Methods;
|
||||
|
||||
namespace View_by_Distance.Instance;
|
||||
@ -36,6 +37,7 @@ public class DlibDotNet
|
||||
public DlibDotNet(List<string> args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
|
||||
{
|
||||
string argZero;
|
||||
Person[] people;
|
||||
_AppSettings = appSettings;
|
||||
if (appSettings.MaxDegreeOfParallelism is null)
|
||||
throw new Exception($"{nameof(appSettings.MaxDegreeOfParallelism)} is null!");
|
||||
@ -49,8 +51,6 @@ public class DlibDotNet
|
||||
Models.Configuration configuration = Models.Stateless.Configuration.Get(isEnvironment, configurationRoot, workingDirectory, propertyConfiguration);
|
||||
Verify(configuration);
|
||||
(Model model, PredictorModel predictorModel) = GetTuple(args, propertyConfiguration, configuration);
|
||||
if (configuration.SearchForAbandonedFilesFull is null)
|
||||
throw new Exception($"{nameof(configuration.SearchForAbandonedFilesFull)} is null!");
|
||||
_Configuration = configuration;
|
||||
_Index = new G_Index(configuration);
|
||||
_Random = new F_Random(configuration);
|
||||
@ -72,6 +72,8 @@ public class DlibDotNet
|
||||
throw new Exception($"{nameof(configuration.PropertiesChangedForMetadata)} is null!");
|
||||
if (configuration.PropertiesChangedForResize is null)
|
||||
throw new Exception($"{nameof(configuration.PropertiesChangedForResize)} is null!");
|
||||
if (configuration.Reverse is null)
|
||||
throw new Exception($"{nameof(configuration.Reverse)} is null!");
|
||||
_Metadata = new(configuration.ForceMetadataLastWriteTimeToCreationTime.Value, configuration.PropertiesChangedForMetadata.Value);
|
||||
if (args.Count > 0)
|
||||
argZero = Path.GetFullPath(args[0]);
|
||||
@ -90,44 +92,21 @@ public class DlibDotNet
|
||||
_Faces = new D_Face(configuration, argZero, model, modelParameter, predictorModel);
|
||||
if (configuration.SkipSearch is null)
|
||||
throw new Exception($"{nameof(configuration.SkipSearch)} is null!");
|
||||
if (_ArgZeroIsConfigurationRootDirectory)
|
||||
_ = _People.GetPeople(propertyConfiguration);
|
||||
if (!_ArgZeroIsConfigurationRootDirectory)
|
||||
people = Array.Empty<Person>();
|
||||
else
|
||||
people = _People.GetPeople(propertyConfiguration);
|
||||
if (!isSilent && configuration.TestDistanceResults.HasValue && configuration.TestDistanceResults.Value)
|
||||
{
|
||||
E2_Navigate e2Navigate = new(console, configuration, argZero);
|
||||
e2Navigate.Navigate(propertyConfiguration, configuration.OutputResolutions[0]);
|
||||
}
|
||||
if (_ArgZeroIsConfigurationRootDirectory)
|
||||
{
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
string[] directories = Property.Models.Stateless.A_Property.GetDirectoryRenameCollection(propertyConfiguration, configuration.OutputResolutions[0], nameof(B_Metadata), nameof(C_Resize));
|
||||
foreach (string directory in directories)
|
||||
{
|
||||
if (!Directory.Exists(directory))
|
||||
continue;
|
||||
Property.Models.Stateless.A_Property.SearchForAbandonedFilesFull(argZero, directory, onlyJson: false);
|
||||
}
|
||||
if (appSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(Property.Models.Stateless.A_Property.SearchForAbandonedFilesFull));
|
||||
e2Navigate.Navigate(propertyConfiguration, model, predictorModel, configuration.OutputResolutions[0]);
|
||||
}
|
||||
if (!configuration.SkipSearch.Value)
|
||||
Search(argZero);
|
||||
Search(propertyConfiguration, configuration.JuliePhares, configuration.Reverse.Value, model, predictorModel, argZero, people);
|
||||
if (_Exceptions.Count == 0 && _ArgZeroIsConfigurationRootDirectory)
|
||||
{
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
if (configuration.SearchForAbandonedFilesFull.Value)
|
||||
{
|
||||
string[] directories = _Rename.GetDirectoryRenameCollection(propertyConfiguration, relativePath: string.Empty, newDirectoryName: string.Empty, jsonFiles4InfoAny: false);
|
||||
foreach (string directory in directories)
|
||||
{
|
||||
if (!Directory.Exists(directory))
|
||||
continue;
|
||||
Property.Models.Stateless.A_Property.SearchForAbandonedFilesFull(argZero, directory, onlyJson: true);
|
||||
}
|
||||
if (appSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(Property.Models.Stateless.A_Property.SearchForAbandonedFilesFull));
|
||||
}
|
||||
List<string[]> directoryCollections = _Rename.GetDirectoryRenameCollections(propertyConfiguration, relativePath: string.Empty, newDirectoryName: string.Empty, jsonFiles4InfoAny: false);
|
||||
List<string[]> directoryCollections = _Rename.GetDirectoryRenameCollections(propertyConfiguration, model, predictorModel, relativePath: string.Empty, newDirectoryName: string.Empty, jsonFiles4InfoAny: false);
|
||||
foreach (string[] directoryCollection in directoryCollections)
|
||||
{
|
||||
_Log.Information(string.Concat("Cleaning <", directoryCollection[0], ">"));
|
||||
@ -149,7 +128,7 @@ public class DlibDotNet
|
||||
{
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
foreach (string outputResolution in configuration.OutputResolutions)
|
||||
_Distance.LoadOrCreateThenSaveDirectoryDistanceResults(propertyConfiguration, outputResolution);
|
||||
_Distance.LoadOrCreateThenSaveDirectoryDistanceResults(propertyConfiguration, model, predictorModel, outputResolution);
|
||||
if (appSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(E_Distance.LoadOrCreateThenSaveDirectoryDistanceResults));
|
||||
}
|
||||
@ -300,8 +279,6 @@ public class DlibDotNet
|
||||
throw new Exception($"{nameof(configuration.SaveFullYearOfRandomFiles)} must be set!");
|
||||
if (configuration.SaveResizedSubfiles is null)
|
||||
throw new Exception($"{nameof(configuration.SaveResizedSubfiles)} must be set!");
|
||||
if (configuration.SearchForAbandonedFilesFull is null)
|
||||
throw new Exception($"{nameof(configuration.SearchForAbandonedFilesFull)} must be set!");
|
||||
if (configuration.SkipSearch is null)
|
||||
throw new Exception($"{nameof(configuration.SkipSearch)} must be set!");
|
||||
if (configuration.TestDistanceResults is null)
|
||||
@ -320,51 +297,10 @@ public class DlibDotNet
|
||||
throw new Exception($"{nameof(configuration.DistanceFactor)} and {nameof(configuration.LocationConfidenceFactor)} must add up to 10!");
|
||||
}
|
||||
|
||||
private int FullParallelWork(object @lock, long ticks, PropertyLogic propertyLogic, string outputResolution, List<Tuple<string, DateTime>> sourceDirectoryChanges, List<FileInfo?> propertyFileInfoCollection, List<A_Property> propertyCollection, List<List<KeyValuePair<string, string>>> metadataCollection, List<Dictionary<string, int[]>> resizeKeyValuePairs, List<List<D_Face>> faceCollections, int g, string sourceDirectory, int r, string[] filteredSourceDirectoryFiles, int count)
|
||||
{
|
||||
int result = 0;
|
||||
if (_Log is null)
|
||||
throw new Exception($"{nameof(_Log)} is null!");
|
||||
if (_AppSettings.MaxDegreeOfParallelism is null)
|
||||
throw new Exception($"{nameof(AppSettings.MaxDegreeOfParallelism)} is null!");
|
||||
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = _AppSettings.MaxDegreeOfParallelism.Value };
|
||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||
if (faceCollections.Count != filteredSourceDirectoryFiles.Length || metadataCollection.Count != filteredSourceDirectoryFiles.Length || resizeKeyValuePairs.Count != filteredSourceDirectoryFiles.Length || propertyCollection.Count != filteredSourceDirectoryFiles.Length)
|
||||
{
|
||||
for (int i = 0; i < filteredSourceDirectoryFiles.Length; i++)
|
||||
{
|
||||
faceCollections.Add(new());
|
||||
metadataCollection.Add(new());
|
||||
resizeKeyValuePairs.Add(new());
|
||||
propertyCollection.Add(new());
|
||||
propertyFileInfoCollection.Add(null);
|
||||
}
|
||||
}
|
||||
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
using (ProgressBar progressBar = new(filteredSourceDirectoryFiles.Length, $"{g}) {r + 1:000} / {count:000} - {outputResolution} - {sourceDirectory} - {filteredSourceDirectoryFiles.Length} file(s) - {totalSeconds} total second(s)", options))
|
||||
{
|
||||
_ = Parallel.For(0, filteredSourceDirectoryFiles.Length, parallelOptions, i =>
|
||||
{
|
||||
try
|
||||
{
|
||||
FullParallelForWork(propertyLogic, @lock, outputResolution, sourceDirectoryChanges, propertyFileInfoCollection, propertyCollection, metadataCollection, resizeKeyValuePairs, faceCollections, sourceDirectory, index: i, filteredSourceDirectoryFiles[i]);
|
||||
if (sourceDirectoryChanges.Any())
|
||||
progressBar.Tick();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result += 1;
|
||||
_Log.Error(string.Concat(sourceDirectory, Environment.NewLine, ex.Message, Environment.NewLine, ex.StackTrace), ex);
|
||||
if (result == filteredSourceDirectoryFiles.Length)
|
||||
throw new Exception(string.Concat("All in [", sourceDirectory, "]failed!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void FullParallelForWork(PropertyLogic propertyLogic, object @lock, string outputResolution, List<Tuple<string, DateTime>> sourceDirectoryChanges, List<FileInfo?> propertyFileInfoCollection, List<A_Property> propertyCollection, List<List<KeyValuePair<string, string>>> metadataCollections, List<Dictionary<string, int[]>> resizeKeyValuePairs, List<List<D_Face>> imageFaceCollections, string sourceDirectory, int index, string filteredSourceDirectoryFile)
|
||||
private void FullParallelForWork(PropertyLogic propertyLogic, object @lock, string outputResolution, List<Tuple<string, DateTime>> sourceDirectoryChanges, List<FileInfo?> propertyFileInfoCollection, List<A_Property> propertyCollection, List<List<KeyValuePair<string, string>>> metadataCollections, List<Dictionary<string, int[]>> resizeKeyValuePairs, List<List<D_Face>> imageFaceCollections, string sourceDirectory, int index, PropertyHolder propertyHolder)
|
||||
{
|
||||
if (propertyHolder.FileInfo is null)
|
||||
throw new Exception($"{nameof(propertyHolder.FileInfo)} is null!");
|
||||
if (_AppSettings.MaxDegreeOfParallelism is null)
|
||||
throw new Exception($"{nameof(_AppSettings.MaxDegreeOfParallelism)} is null!");
|
||||
if (_Configuration.SaveResizedSubfiles is null)
|
||||
@ -373,6 +309,7 @@ public class DlibDotNet
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration)} must be set!");
|
||||
if (_Configuration.PropertyConfiguration.WriteBitmapDataBytes is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.WriteBitmapDataBytes)} is null!");
|
||||
A_Property property;
|
||||
List<D_Face> faceCollection;
|
||||
string original = "Original";
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
@ -381,29 +318,36 @@ public class DlibDotNet
|
||||
Dictionary<string, int[]> imageResizeKeyValuePairs;
|
||||
List<Tuple<string, DateTime>> subFileTuples = new();
|
||||
List<KeyValuePair<string, string>> metadataCollection;
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filteredSourceDirectoryFile);
|
||||
string relativePath = Property.Models.Stateless.IPath.GetRelativePath(filteredSourceDirectoryFile, _Configuration.PropertyConfiguration.RootDirectory.Length);
|
||||
FileInfo propertyFileInfo = new(Path.Combine(propertyLogic.AngleBracketCollection[0].Replace("<>", "{}"), string.Concat(fileNameWithoutExtension, ".json")));
|
||||
A_Property property = propertyLogic.GetProperty(propertyLogic.AngleBracketCollection[0], sourceDirectory, filteredSourceDirectoryFile, subFileTuples, parseExceptions, propertyFileInfo);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(PropertyLogic.GetProperty));
|
||||
(int metadataGroups, metadataCollection) = _Metadata.GetMetadataCollection(subFileTuples, parseExceptions, filteredSourceDirectoryFile, relativePath, fileNameWithoutExtension);
|
||||
if (propertyHolder.Property is null)
|
||||
{
|
||||
sourceDirectoryChanges.Add(new Tuple<string, DateTime>(nameof(A_Property), propertyHolder.FileInfo.LastWriteTime));
|
||||
property = propertyLogic.GetProperty(propertyLogic.AngleBracketCollection[0], sourceDirectory, propertyHolder.FileInfo.FullName, subFileTuples, parseExceptions, propertyHolder.FileInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
property = propertyHolder.Property;
|
||||
if (propertyHolder.Changed.HasValue && propertyHolder.Changed.Value)
|
||||
sourceDirectoryChanges.Add(new Tuple<string, DateTime>(nameof(A_Property), propertyHolder.FileInfo.LastWriteTime));
|
||||
}
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(propertyHolder.FileInfo.FullName);
|
||||
(int metadataGroups, metadataCollection) = _Metadata.GetMetadataCollection(subFileTuples, parseExceptions, propertyHolder.FileInfo.FullName, propertyHolder.RelativePath, fileNameWithoutExtension);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(B_Metadata.GetMetadataCollection));
|
||||
FileInfo resizedFileInfo = new(Path.Combine(_Resize.AngleBracketCollection[0].Replace("<>", "()"), Path.GetFileName(filteredSourceDirectoryFile)));
|
||||
imageResizeKeyValuePairs = _Resize.GetResizeKeyValuePairs(subFileTuples, parseExceptions, original, metadataCollection, property, filteredSourceDirectoryFile, relativePath, fileNameWithoutExtension);
|
||||
FileInfo resizedFileInfo = new(Path.Combine(_Resize.AngleBracketCollection[0].Replace("<>", "()"), Path.GetFileName(propertyHolder.FileInfo.FullName)));
|
||||
propertyHolder.SetResizedFileInfo(resizedFileInfo);
|
||||
imageResizeKeyValuePairs = _Resize.GetResizeKeyValuePairs(subFileTuples, parseExceptions, original, metadataCollection, property, propertyHolder.FileInfo.FullName, propertyHolder.RelativePath, fileNameWithoutExtension);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(C_Resize.GetResizeKeyValuePairs));
|
||||
if (_Configuration.SaveResizedSubfiles.Value)
|
||||
{
|
||||
_Resize.SaveResizedSubfile(outputResolution, subFileTuples, filteredSourceDirectoryFile, original, property, imageResizeKeyValuePairs, resizedFileInfo);
|
||||
_Resize.SaveResizedSubfile(outputResolution, subFileTuples, propertyHolder.FileInfo.FullName, original, property, imageResizeKeyValuePairs, resizedFileInfo);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(C_Resize.SaveResizedSubfile));
|
||||
resizedFileInfo.Refresh();
|
||||
}
|
||||
else if (outputResolution == _Configuration.OutputResolutions[0] && false)
|
||||
{
|
||||
byte[] bytes = _Resize.GetResizedBytes(outputResolution, subFileTuples, filteredSourceDirectoryFile, property, imageResizeKeyValuePairs);
|
||||
byte[] bytes = _Resize.GetResizedBytes(outputResolution, subFileTuples, propertyHolder.FileInfo.FullName, property, imageResizeKeyValuePairs);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(C_Resize.GetResizedBytes));
|
||||
string path = Path.Combine(resizedFileInfo.DirectoryName, Path.GetFileNameWithoutExtension(resizedFileInfo.Name));
|
||||
@ -417,15 +361,15 @@ public class DlibDotNet
|
||||
int outputResolutionWidth = outputResolutionCollection[0];
|
||||
int outputResolutionHeight = outputResolutionCollection[1];
|
||||
int outputResolutionOrientation = outputResolutionCollection[2];
|
||||
faceCollection = _Faces.GetFaces(_Configuration.PropertyConfiguration, outputResolution, subFileTuples, parseExceptions, relativePath, fileNameWithoutExtension, property, resizedFileInfo, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation);
|
||||
faceCollection = _Faces.GetFaces(_Configuration.PropertyConfiguration, outputResolution, subFileTuples, parseExceptions, propertyHolder.RelativePath, fileNameWithoutExtension, property, resizedFileInfo, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(D_Face.GetFaces));
|
||||
_Faces.SaveFaces(_Configuration.PropertyConfiguration, subFileTuples, parseExceptions, relativePath, fileNameWithoutExtension, resizedFileInfo, faceCollection);
|
||||
_Faces.SaveFaces(_Configuration.PropertyConfiguration, subFileTuples, parseExceptions, propertyHolder.RelativePath, fileNameWithoutExtension, resizedFileInfo, faceCollection);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(D_Face.SaveFaces));
|
||||
if (_Configuration.SaveFaceLandmarkForOutputResolutions.Contains(outputResolution))
|
||||
{
|
||||
_FaceLandmarks.SaveFaceLandmarkImages(subFileTuples, parseExceptions, relativePath, fileNameWithoutExtension, resizedFileInfo, faceCollection);
|
||||
_FaceLandmarks.SaveFaceLandmarkImages(subFileTuples, parseExceptions, propertyHolder.RelativePath, fileNameWithoutExtension, resizedFileInfo, faceCollection);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(D2_FaceLandmarks.SaveFaceLandmarkImages));
|
||||
}
|
||||
@ -435,12 +379,55 @@ public class DlibDotNet
|
||||
propertyCollection[index] = property;
|
||||
imageFaceCollections[index] = faceCollection;
|
||||
metadataCollections[index] = metadataCollection;
|
||||
propertyFileInfoCollection[index] = propertyFileInfo;
|
||||
resizeKeyValuePairs[index] = imageResizeKeyValuePairs;
|
||||
propertyFileInfoCollection[index] = propertyHolder.FileInfo;
|
||||
sourceDirectoryChanges.AddRange(from l in subFileTuples where l.Item2 > dateTime select l);
|
||||
}
|
||||
}
|
||||
|
||||
private int FullParallelWork(object @lock, long ticks, PropertyLogic propertyLogic, string outputResolution, List<Tuple<string, DateTime>> sourceDirectoryChanges, List<FileInfo?> propertyFileInfoCollection, List<A_Property> propertyCollection, List<List<KeyValuePair<string, string>>> metadataCollection, List<Dictionary<string, int[]>> resizeKeyValuePairs, List<List<D_Face>> faceCollections, int propertyHolderCollectionsCount, int g, string sourceDirectory, int r, PropertyHolder[] filteredPropertyHolderCollection)
|
||||
{
|
||||
int result = 0;
|
||||
if (_Log is null)
|
||||
throw new Exception($"{nameof(_Log)} is null!");
|
||||
if (_AppSettings.MaxDegreeOfParallelism is null)
|
||||
throw new Exception($"{nameof(AppSettings.MaxDegreeOfParallelism)} is null!");
|
||||
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = _AppSettings.MaxDegreeOfParallelism.Value };
|
||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||
if (faceCollections.Count != filteredPropertyHolderCollection.Length || metadataCollection.Count != filteredPropertyHolderCollection.Length || resizeKeyValuePairs.Count != filteredPropertyHolderCollection.Length || propertyCollection.Count != filteredPropertyHolderCollection.Length)
|
||||
{
|
||||
for (int i = 0; i < filteredPropertyHolderCollection.Length; i++)
|
||||
{
|
||||
faceCollections.Add(new());
|
||||
metadataCollection.Add(new());
|
||||
resizeKeyValuePairs.Add(new());
|
||||
propertyCollection.Add(new());
|
||||
propertyFileInfoCollection.Add(null);
|
||||
}
|
||||
}
|
||||
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
using (ProgressBar progressBar = new(filteredPropertyHolderCollection.Length, $"{r + 1:000}.{g} / {propertyHolderCollectionsCount:000}) {filteredPropertyHolderCollection.Length:000} file(s) - {totalSeconds} total second(s) - {outputResolution} - {sourceDirectory}", options))
|
||||
{
|
||||
_ = Parallel.For(0, filteredPropertyHolderCollection.Length, parallelOptions, i =>
|
||||
{
|
||||
try
|
||||
{
|
||||
FullParallelForWork(propertyLogic, @lock, outputResolution, sourceDirectoryChanges, propertyFileInfoCollection, propertyCollection, metadataCollection, resizeKeyValuePairs, faceCollections, sourceDirectory, index: i, filteredPropertyHolderCollection[i]);
|
||||
if (sourceDirectoryChanges.Any())
|
||||
progressBar.Tick();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result += 1;
|
||||
_Log.Error(string.Concat(sourceDirectory, Environment.NewLine, ex.Message, Environment.NewLine, ex.StackTrace), ex);
|
||||
if (result == filteredPropertyHolderCollection.Length)
|
||||
throw new Exception(string.Concat("All in [", sourceDirectory, "] failed!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void WriteTab(string checkDirectory, List<(string Id, string Line)> metadataIdLines, string fileName)
|
||||
{
|
||||
string text;
|
||||
@ -476,14 +463,12 @@ public class DlibDotNet
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteGroup(PropertyLogic propertyLogic, List<A_Property> propertyCollection, List<List<KeyValuePair<string, string>>> metadataCollection, List<List<D_Face>> faceCollections, List<Dictionary<string, int[]>> resizeKeyValuePairs, string sourceDirectory, string[] filteredSourceDirectoryFiles)
|
||||
private void WriteGroup(Property.Models.Configuration configuration, PropertyLogic propertyLogic, List<A_Property> propertyCollection, List<List<KeyValuePair<string, string>>> metadataCollection, List<List<D_Face>> faceCollections, List<Dictionary<string, int[]>> resizeKeyValuePairs, string sourceDirectory, PropertyHolder[] filteredPropertyHolderCollection)
|
||||
{
|
||||
if (_Configuration.PropertiesChangedForMetadata is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertiesChangedForMetadata)} is null!");
|
||||
if (_Configuration?.PropertyConfiguration is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration)} must be set!");
|
||||
if (_Configuration.PropertyConfiguration.PropertiesChangedForProperty is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.PropertiesChangedForProperty)} is null!");
|
||||
if (configuration.PropertiesChangedForProperty is null)
|
||||
throw new Exception($"{nameof(configuration.PropertiesChangedForProperty)} is null!");
|
||||
if (_Configuration.PropertiesChangedForResize is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertiesChangedForResize)} is null!");
|
||||
if (_Configuration.PropertiesChangedForFaces is null)
|
||||
@ -491,8 +476,10 @@ public class DlibDotNet
|
||||
string key;
|
||||
string json;
|
||||
string checkFile;
|
||||
PropertyHolder propertyHolder;
|
||||
int sourceDirectoryLength = sourceDirectory.Length;
|
||||
int rootDirectoryLength = _Configuration.PropertyConfiguration.RootDirectory.Length;
|
||||
int rootDirectoryLength = configuration.RootDirectory.Length;
|
||||
_FilePropertiesKeyValuePairs.Add(sourceDirectory, new List<Tuple<string, A_Property>>());
|
||||
JsonSerializerOptions writeIndentedJsonSerializerOptions = new() { WriteIndented = false };
|
||||
if (!(from l in propertyCollection where l?.Width is null select true).Any())
|
||||
{
|
||||
@ -501,11 +488,18 @@ public class DlibDotNet
|
||||
List<KeyValuePair<string, A_Property>> propertyCollectionKeyValuePairs = new();
|
||||
List<KeyValuePair<string, Dictionary<string, int[]>>> resizeKeyValuePairsCollections = new();
|
||||
List<KeyValuePair<string, List<KeyValuePair<string, string>>>> metadataCollectionKeyValuePairs = new();
|
||||
(int level, List<string> directories) = Property.Models.Stateless.IPath.Get(_Configuration.PropertyConfiguration.RootDirectory, sourceDirectory);
|
||||
string fileName = string.Concat(string.Join(_Configuration.PropertyConfiguration.FileNameDirectorySeparator, directories), ".json");
|
||||
for (int i = 0; i < filteredSourceDirectoryFiles.Length; i++)
|
||||
(int level, List<string> directories) = Property.Models.Stateless.IPath.Get(configuration.RootDirectory, sourceDirectory);
|
||||
string fileName = string.Concat(string.Join(configuration.FileNameDirectorySeparator, directories), ".json");
|
||||
for (int i = 0; i < filteredPropertyHolderCollection.Length; i++)
|
||||
{
|
||||
key = Property.Models.Stateless.IPath.GetRelativePath(filteredSourceDirectoryFiles[i], sourceDirectoryLength);
|
||||
propertyHolder = filteredPropertyHolderCollection[i];
|
||||
if (propertyHolder.Property is null)
|
||||
continue;
|
||||
if (propertyHolder.FileInfo is null)
|
||||
continue;
|
||||
key = Property.Models.Stateless.IPath.GetRelativePath(propertyHolder.FileInfo.FullName, sourceDirectoryLength);
|
||||
_FileKeyValuePairs.Add(new KeyValuePair<string, string>(sourceDirectory, key));
|
||||
_FilePropertiesKeyValuePairs[sourceDirectory].Add(new Tuple<string, A_Property>(key, propertyCollection[i]));
|
||||
faceCollectionsKeyValuePairs.Add(new KeyValuePair<string, List<D_Face>>(key, faceCollections[i]));
|
||||
propertyCollectionKeyValuePairs.Add(new KeyValuePair<string, A_Property>(key, propertyCollection[i]));
|
||||
resizeKeyValuePairsCollections.Add(new KeyValuePair<string, Dictionary<string, int[]>>(key, resizeKeyValuePairs[i]));
|
||||
@ -554,131 +548,135 @@ public class DlibDotNet
|
||||
}
|
||||
}
|
||||
|
||||
private void FullDoWork(List<string> topDirectories, List<(int g, string sourceDirectory, string[] sourceDirectoryFiles, int r)> groupCollection)
|
||||
private void FullDoWork(Property.Models.Configuration configuration, string[] juliePhares, Model model, PredictorModel predictorModel, string argZero, Person[] people, PropertyLogic propertyLogic, List<PropertyHolder[]> propertyHolderCollections)
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new Exception($"{nameof(_Log)} is null!");
|
||||
if (_AppSettings.MaxDegreeOfParallelism is null)
|
||||
throw new Exception($"{nameof(_AppSettings.MaxDegreeOfParallelism)} is null!");
|
||||
if (_Configuration?.PropertyConfiguration is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration)} must be set!");
|
||||
if (_Configuration.PropertyConfiguration.ForcePropertyLastWriteTimeToCreationTime is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.ForcePropertyLastWriteTimeToCreationTime)} is null!");
|
||||
if (_Configuration.LoadOrCreateThenSaveImageFacesResults is null)
|
||||
throw new Exception($"{nameof(_Configuration.LoadOrCreateThenSaveImageFacesResults)} is null!");
|
||||
if (_Configuration.LoadOrCreateThenSaveDirectoryDistanceResults is null)
|
||||
throw new Exception($"{nameof(_Configuration.LoadOrCreateThenSaveDirectoryDistanceResults)} is null!");
|
||||
if (_Configuration.LoadOrCreateThenSaveDistanceResults is null)
|
||||
throw new Exception($"{nameof(_Configuration.LoadOrCreateThenSaveDistanceResults)} is null!");
|
||||
if (_Configuration.PropertyConfiguration.MaxImagesInDirectoryForTopLevelFirstPass is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.MaxImagesInDirectoryForTopLevelFirstPass)} is null!");
|
||||
if (_Configuration.PropertyConfiguration.PopulatePropertyId is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.PopulatePropertyId)} is null!");
|
||||
if (_Configuration.PropertyConfiguration.PropertiesChangedForProperty is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.PropertiesChangedForProperty)} is null!");
|
||||
if (_Configuration.PropertyConfiguration.WriteBitmapDataBytes is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.WriteBitmapDataBytes)} is null!");
|
||||
int g;
|
||||
int r;
|
||||
int exceptionCount;
|
||||
object @lock = new();
|
||||
string sourceDirectory;
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
string[] filteredSourceDirectoryFiles;
|
||||
string modelName = model.ToString();
|
||||
List<List<D_Face>> faceCollections = new();
|
||||
List<A_Property> propertyCollection = new();
|
||||
PropertyLogic propertyLogic = GetPropertyLogic();
|
||||
PropertyHolder[] filteredPropertyHolderCollection;
|
||||
List<FileInfo?> propertyFileInfoCollection = new();
|
||||
string predictorModelName = predictorModel.ToString();
|
||||
List<Dictionary<string, int[]>> resizeKeyValuePairs = new();
|
||||
List<Tuple<string, DateTime>> sourceDirectoryChanges = new();
|
||||
string propertyRoot = Property.Models.Stateless.IResult.GetResultsGroupDirectory(_Configuration.PropertyConfiguration, nameof(A_Property));
|
||||
List<List<KeyValuePair<string, string>>> metadataCollection = new();
|
||||
string aPropertySingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(A_Property), "{}");
|
||||
string propertyRoot = Property.Models.Stateless.IResult.GetResultsGroupDirectory(configuration, nameof(A_Property));
|
||||
foreach (string outputResolution in _Configuration.OutputResolutions)
|
||||
{
|
||||
_FileKeyValuePairs.Clear();
|
||||
_FilePropertiesKeyValuePairs.Clear();
|
||||
foreach ((int g, string sourceDirectory, string[] sourceDirectoryFiles, int r) in groupCollection)
|
||||
foreach (PropertyHolder[] propertyHolderCollection in propertyHolderCollections)
|
||||
{
|
||||
if (!topDirectories.Any())
|
||||
if (!propertyHolderCollection.Any())
|
||||
continue;
|
||||
if (!_ArgZeroIsConfigurationRootDirectory && !propertyHolderCollection[0].SourceDirectory.StartsWith(argZero))
|
||||
continue;
|
||||
filteredPropertyHolderCollection = (from l in propertyHolderCollection where l.FileInfo is not null && l.Property is not null && l.ValidImageFormatExtension.HasValue && l.ValidImageFormatExtension.Value && !_Configuration.IgnoreExtensions.Contains(l.FileInfo.Extension) select l).ToArray();
|
||||
if (!filteredPropertyHolderCollection.Any())
|
||||
continue;
|
||||
faceCollections.Clear();
|
||||
metadataCollection.Clear();
|
||||
propertyCollection.Clear();
|
||||
resizeKeyValuePairs.Clear();
|
||||
sourceDirectoryChanges.Clear();
|
||||
propertyFileInfoCollection.Clear();
|
||||
_Faces.AngleBracketCollection.Clear();
|
||||
_Resize.AngleBracketCollection.Clear();
|
||||
_Metadata.AngleBracketCollection.Clear();
|
||||
g = filteredPropertyHolderCollection[0].G;
|
||||
r = filteredPropertyHolderCollection[0].R;
|
||||
propertyLogic.AngleBracketCollection.Clear();
|
||||
_FaceLandmarks.AngleBracketCollection.Clear();
|
||||
filteredSourceDirectoryFiles = (from l in sourceDirectoryFiles where !_Configuration.IgnoreExtensions.Contains(Path.GetExtension(l)) select l).ToArray();
|
||||
if (!filteredSourceDirectoryFiles.Any())
|
||||
continue;
|
||||
propertyLogic.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(_Configuration.PropertyConfiguration,
|
||||
sourceDirectory,
|
||||
nameof(A_Property),
|
||||
outputResolution,
|
||||
includeResizeGroup: false,
|
||||
includeModel: false,
|
||||
includePredictorModel: false,
|
||||
contentDescription: string.Empty,
|
||||
singletonDescription: "Properties for each image",
|
||||
collectionDescription: string.Empty));
|
||||
_Metadata.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(_Configuration.PropertyConfiguration,
|
||||
sourceDirectory,
|
||||
nameof(B_Metadata),
|
||||
outputResolution,
|
||||
includeResizeGroup: false,
|
||||
includeModel: false,
|
||||
includePredictorModel: false,
|
||||
contentDescription: string.Empty,
|
||||
singletonDescription: "Metadata as key value pairs",
|
||||
collectionDescription: string.Empty));
|
||||
_Resize.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(_Configuration.PropertyConfiguration,
|
||||
sourceDirectory,
|
||||
nameof(C_Resize),
|
||||
outputResolution,
|
||||
includeResizeGroup: true,
|
||||
includeModel: false,
|
||||
includePredictorModel: false,
|
||||
contentDescription: "Resized image",
|
||||
singletonDescription: "Resize deminsions for each resolution",
|
||||
collectionDescription: string.Empty));
|
||||
if (_Configuration.LoadOrCreateThenSaveImageFacesResults.HasValue && _Configuration.LoadOrCreateThenSaveImageFacesResults.Value)
|
||||
_Faces.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(_Configuration.PropertyConfiguration,
|
||||
sourceDirectory,
|
||||
nameof(D_Face),
|
||||
outputResolution,
|
||||
includeResizeGroup: true,
|
||||
includeModel: true,
|
||||
includePredictorModel: true,
|
||||
contentDescription: "n png file(s) for each face found",
|
||||
singletonDescription: string.Empty,
|
||||
collectionDescription: "For each image a json file with all faces found"));
|
||||
if (_Configuration.SaveFaceLandmarkForOutputResolutions.Contains(outputResolution))
|
||||
_FaceLandmarks.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(_Configuration.PropertyConfiguration,
|
||||
sourceDirectory = filteredPropertyHolderCollection[0].SourceDirectory;
|
||||
propertyLogic.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
||||
modelName,
|
||||
predictorModelName,
|
||||
sourceDirectory,
|
||||
nameof(D2_FaceLandmarks),
|
||||
nameof(A_Property),
|
||||
outputResolution,
|
||||
includeResizeGroup: true,
|
||||
includeModel: true,
|
||||
includePredictorModel: true,
|
||||
contentDescription: "n x 2 png file(s) for each face found",
|
||||
singletonDescription: string.Empty,
|
||||
includeResizeGroup: false,
|
||||
includeModel: false,
|
||||
includePredictorModel: false,
|
||||
contentDescription: string.Empty,
|
||||
singletonDescription: "Properties for each image",
|
||||
collectionDescription: string.Empty));
|
||||
exceptionCount = FullParallelWork(@lock, ticks, propertyLogic, outputResolution, sourceDirectoryChanges, propertyFileInfoCollection, propertyCollection, metadataCollection, resizeKeyValuePairs, faceCollections, g, sourceDirectory, r, filteredSourceDirectoryFiles, groupCollection.Count);
|
||||
if (metadataCollection.Count != filteredSourceDirectoryFiles.Length || propertyCollection.Count != filteredSourceDirectoryFiles.Length || resizeKeyValuePairs.Count != filteredSourceDirectoryFiles.Length || faceCollections.Count != filteredSourceDirectoryFiles.Length)
|
||||
_Metadata.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
||||
modelName,
|
||||
predictorModelName,
|
||||
sourceDirectory,
|
||||
nameof(B_Metadata),
|
||||
outputResolution,
|
||||
includeResizeGroup: false,
|
||||
includeModel: false,
|
||||
includePredictorModel: false,
|
||||
contentDescription: string.Empty,
|
||||
singletonDescription: "Metadata as key value pairs",
|
||||
collectionDescription: string.Empty));
|
||||
_Resize.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
||||
modelName,
|
||||
predictorModelName,
|
||||
sourceDirectory,
|
||||
nameof(C_Resize),
|
||||
outputResolution,
|
||||
includeResizeGroup: true,
|
||||
includeModel: false,
|
||||
includePredictorModel: false,
|
||||
contentDescription: "Resized image",
|
||||
singletonDescription: "Resize dimensions for each resolution",
|
||||
collectionDescription: string.Empty));
|
||||
if (_Configuration.LoadOrCreateThenSaveImageFacesResults.HasValue && _Configuration.LoadOrCreateThenSaveImageFacesResults.Value)
|
||||
_Faces.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
||||
modelName,
|
||||
predictorModelName,
|
||||
sourceDirectory,
|
||||
nameof(D_Face),
|
||||
outputResolution,
|
||||
includeResizeGroup: true,
|
||||
includeModel: true,
|
||||
includePredictorModel: true,
|
||||
contentDescription: "n png file(s) for each face found",
|
||||
singletonDescription: string.Empty,
|
||||
collectionDescription: "For each image a json file with all faces found"));
|
||||
if (_Configuration.SaveFaceLandmarkForOutputResolutions.Contains(outputResolution))
|
||||
_FaceLandmarks.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
||||
modelName,
|
||||
predictorModelName,
|
||||
sourceDirectory,
|
||||
nameof(D2_FaceLandmarks),
|
||||
outputResolution,
|
||||
includeResizeGroup: true,
|
||||
includeModel: true,
|
||||
includePredictorModel: true,
|
||||
contentDescription: "n x 2 png file(s) for each face found",
|
||||
singletonDescription: string.Empty,
|
||||
collectionDescription: string.Empty));
|
||||
exceptionCount = FullParallelWork(@lock, ticks, propertyLogic, outputResolution, sourceDirectoryChanges, propertyFileInfoCollection, propertyCollection, metadataCollection, resizeKeyValuePairs, faceCollections, propertyHolderCollections.Count, g, sourceDirectory, r, filteredPropertyHolderCollection);
|
||||
if (metadataCollection.Count != filteredPropertyHolderCollection.Length || propertyCollection.Count != filteredPropertyHolderCollection.Length || resizeKeyValuePairs.Count != filteredPropertyHolderCollection.Length || faceCollections.Count != filteredPropertyHolderCollection.Length)
|
||||
throw new Exception("Counts don't match!");
|
||||
if (exceptionCount != 0)
|
||||
_Exceptions.Add(sourceDirectory);
|
||||
else
|
||||
{
|
||||
string key;
|
||||
int rootDirectoryLength = _Configuration.PropertyConfiguration.RootDirectory.Length;
|
||||
_FilePropertiesKeyValuePairs.Add(sourceDirectory, new List<Tuple<string, A_Property>>());
|
||||
for (int i = 0; i < filteredSourceDirectoryFiles.Length; i++)
|
||||
{
|
||||
key = Property.Models.Stateless.IPath.GetRelativePath(filteredSourceDirectoryFiles[i], rootDirectoryLength);
|
||||
_FileKeyValuePairs.Add(new KeyValuePair<string, string>(sourceDirectory, key));
|
||||
_FilePropertiesKeyValuePairs[sourceDirectory].Add(new Tuple<string, A_Property>(key, propertyCollection[i]));
|
||||
}
|
||||
}
|
||||
if (exceptionCount == 0 && _ArgZeroIsConfigurationRootDirectory)
|
||||
WriteGroup(propertyLogic, propertyCollection, metadataCollection, faceCollections, resizeKeyValuePairs, sourceDirectory, filteredSourceDirectoryFiles);
|
||||
WriteGroup(configuration, propertyLogic, propertyCollection, metadataCollection, faceCollections, resizeKeyValuePairs, sourceDirectory, filteredPropertyHolderCollection);
|
||||
if (exceptionCount == 0 && _Configuration.LoadOrCreateThenSaveImageFacesResults.Value && _Configuration.SaveShortcuts.HasValue && _Configuration.SaveShortcuts.Value)
|
||||
_Faces.SaveShortcuts(configuration, juliePhares, model, predictorModel, people, propertyLogic, outputResolution, filteredPropertyHolderCollection, propertyCollection, faceCollections);
|
||||
if (exceptionCount == 0 && _Configuration.LoadOrCreateThenSaveDistanceResults.HasValue && _Configuration.LoadOrCreateThenSaveDistanceResults.Value)
|
||||
_Distance.LoadOrCreateThenSaveDistanceResults(_Configuration.PropertyConfiguration, sourceDirectory, outputResolution, sourceDirectoryChanges, filteredSourceDirectoryFiles, faceCollections);
|
||||
_Distance.LoadOrCreateThenSaveDistanceResults(configuration, model, predictorModel, sourceDirectory, outputResolution, sourceDirectoryChanges, filteredPropertyHolderCollection, faceCollections);
|
||||
if (_Resize.AngleBracketCollection.Any())
|
||||
_ = Property.Models.Stateless.IPath.DeleteEmptyDirectories(_Resize.AngleBracketCollection[0].Replace("<>", "()"));
|
||||
if (_Faces.AngleBracketCollection.Any())
|
||||
@ -690,7 +688,7 @@ public class DlibDotNet
|
||||
for (int y = 0; y < int.MaxValue; y++)
|
||||
{
|
||||
_Log.Information("Press \"Y\" key when ready to continue or close console");
|
||||
if (Console.ReadKey().Key == ConsoleKey.Y)
|
||||
if (System.Console.ReadKey().Key == ConsoleKey.Y)
|
||||
break;
|
||||
}
|
||||
_Log.Information(". . .");
|
||||
@ -698,31 +696,20 @@ public class DlibDotNet
|
||||
}
|
||||
if (_ArgZeroIsConfigurationRootDirectory && outputResolution == _Configuration.OutputResolutions[0])
|
||||
{
|
||||
int loadLessThan = 7;
|
||||
string aPropertySingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(A_Property), "{}");
|
||||
PropertyCompare.Models.PropertyCompareLogic propertyCompareLogic = new(_AppSettings.MaxDegreeOfParallelism.Value, _Configuration.PropertyConfiguration);
|
||||
PropertyCompare.Models.PropertyCompare[] propertyCompares = propertyCompareLogic.Get(aPropertySingletonDirectory, loadLessThan);
|
||||
{
|
||||
string[] lines = (from l in propertyCompares select l.GetSelect()).ToArray();
|
||||
string aPropertyCollectionDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(A_Property), "[{}]");
|
||||
File.WriteAllLines(Path.Join(aPropertyCollectionDirectory, $". . . Ids - {ticks}.txt"), lines);
|
||||
string json = JsonSerializer.Serialize(propertyCompares, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(Path.Join(aPropertyCollectionDirectory, $". . . Ids - {ticks}.nosj"), json);
|
||||
}
|
||||
if (!_Configuration.LoadOrCreateThenSaveImageFacesResults.Value && !_Configuration.LoadOrCreateThenSaveDirectoryDistanceResults.Value && !_Configuration.LoadOrCreateThenSaveDistanceResults.Value)
|
||||
break;
|
||||
if (_Exceptions.Count == 0)
|
||||
{
|
||||
if (_FileKeyValuePairs.Any())
|
||||
_Random.Random(_Configuration.PropertyConfiguration, _Configuration.OutputResolutions[0], _FileKeyValuePairs);
|
||||
_Random.Random(configuration, _Configuration.OutputResolutions[0], _FileKeyValuePairs);
|
||||
if (_IsEnvironment.Development)
|
||||
continue;
|
||||
G2_Identify identify = new(_Configuration);
|
||||
List<G2_Identify> identifiedCollection = identify.GetIdentifiedCollection(_Configuration.PropertyConfiguration, _IsEnvironment, _People);
|
||||
_People.WriteAllText(_Configuration.PropertyConfiguration, _Configuration.OutputResolutions[0], identifiedCollection);
|
||||
identify.WriteAllText(_Configuration.PropertyConfiguration, _Configuration.OutputResolutions[0], identifiedCollection);
|
||||
List<G2_Identify> identifiedCollection = identify.GetIdentifiedCollection(configuration, _IsEnvironment, _People);
|
||||
_People.WriteAllText(configuration, _Configuration.OutputResolutions[0], identifiedCollection);
|
||||
identify.WriteAllText(configuration, _Configuration.OutputResolutions[0], identifiedCollection);
|
||||
if (_Configuration.LoadOrCreateThenSaveIndex.HasValue && _Configuration.LoadOrCreateThenSaveIndex.Value && _FilePropertiesKeyValuePairs.Any())
|
||||
_Index.SetIndex(_Configuration.PropertyConfiguration, _Configuration.OutputResolutions[0], _FilePropertiesKeyValuePairs);
|
||||
_Index.SetIndex(configuration, model, predictorModel, _Configuration.OutputResolutions[0], _FilePropertiesKeyValuePairs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -731,66 +718,21 @@ public class DlibDotNet
|
||||
private PropertyLogic GetPropertyLogic()
|
||||
{
|
||||
PropertyLogic result;
|
||||
|
||||
|
||||
string[] verifyToSeason = Array.Empty<string>();
|
||||
|
||||
|
||||
if (_AppSettings.MaxDegreeOfParallelism is null)
|
||||
throw new Exception($"{nameof(_AppSettings.MaxDegreeOfParallelism)} is null!");
|
||||
if (_Configuration?.PropertyConfiguration is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration)} must be set!");
|
||||
result = new(_AppSettings.MaxDegreeOfParallelism.Value, _Configuration.PropertyConfiguration, verifyToSeason);
|
||||
result = new(_AppSettings.MaxDegreeOfParallelism.Value, _Configuration.PropertyConfiguration);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void Search(string argZero)
|
||||
private void Search(Property.Models.Configuration configuration, string[] juliePhares, bool reverse, Model model, PredictorModel predictorModel, string argZero, Person[] people)
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new Exception($"{nameof(_Log)} is null!");
|
||||
if (_AppSettings.MaxDegreeOfParallelism is null)
|
||||
throw new Exception($"{nameof(_AppSettings.MaxDegreeOfParallelism)} is null!");
|
||||
if (_Configuration?.PropertyConfiguration is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration)} must be set!");
|
||||
if (_Configuration.PropertyConfiguration.ForcePropertyLastWriteTimeToCreationTime is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.ForcePropertyLastWriteTimeToCreationTime)} is null!");
|
||||
if (_Configuration.PropertyConfiguration.IgnoreExtensions is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.IgnoreExtensions)} is null!");
|
||||
if (_Configuration.PropertyConfiguration.MaxImagesInDirectoryForTopLevelFirstPass is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.MaxImagesInDirectoryForTopLevelFirstPass)} is null!");
|
||||
if (_Configuration.PropertyConfiguration.PopulatePropertyId is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.PopulatePropertyId)} is null!");
|
||||
if (_Configuration.PropertyConfiguration.PropertiesChangedForProperty is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.PropertiesChangedForProperty)} is null!");
|
||||
if (_Configuration.Reverse is null)
|
||||
throw new Exception($"{nameof(_Configuration.Reverse)} is null!");
|
||||
if (_Configuration.PropertyConfiguration.WriteBitmapDataBytes is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.WriteBitmapDataBytes)} is null!");
|
||||
string searchPattern = "*";
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
List<string> topDirectories = new();
|
||||
PropertyLogic propertyLogic = GetPropertyLogic();
|
||||
List<(int g, string sourceDirectory, string[] sourceDirectoryFiles, int r)> groupCollection = Property.Models.Stateless.A_Property.GetGroupCollection(argZero, searchPattern, topDirectories, _Configuration.PropertyConfiguration.MaxImagesInDirectoryForTopLevelFirstPass.Value, _Configuration.Reverse.Value);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(Property.Models.Stateless.A_Property.GetGroupCollection));
|
||||
_Exceptions.AddRange(propertyLogic.DoWork(_Configuration.PropertyConfiguration, topDirectories, groupCollection, firstPass: true));
|
||||
string message = $"There were {_Exceptions.Count} exception(s) thrown! {Environment.NewLine}{string.Join(Environment.NewLine, _Exceptions)}";
|
||||
_Log.Information(message);
|
||||
if (_Exceptions.Count != 0)
|
||||
throw new Exception(message);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(Property.Models.Stateless.A_Property.GetGroupCollection));
|
||||
groupCollection = Property.Models.Stateless.A_Property.GetGroupCollection(argZero, searchPattern, topDirectories, _Configuration.PropertyConfiguration.MaxImagesInDirectoryForTopLevelFirstPass.Value, _Configuration.Reverse.Value);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(Property.Models.Stateless.A_Property.GetGroupCollection));
|
||||
FullDoWork(topDirectories, groupCollection);
|
||||
List<PropertyHolder[]> propertyHolderCollections = Property.Models.Stateless.A_Property.Get(configuration, reverse, model.ToString(), predictorModel.ToString(), propertyLogic);
|
||||
FullDoWork(configuration, juliePhares, model, predictorModel, argZero, people, propertyLogic, propertyHolderCollections);
|
||||
}
|
||||
|
||||
internal void RenameQueue()
|
||||
{
|
||||
if (_Configuration?.PropertyConfiguration is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration)} must be set!");
|
||||
_Rename.RenameQueue(_Configuration.PropertyConfiguration);
|
||||
}
|
||||
internal void RenameQueue(Property.Models.Configuration configuration, Model model, PredictorModel predictorModel) => _Rename.RenameQueue(configuration, model, predictorModel);
|
||||
|
||||
}
|
Reference in New Issue
Block a user