Z_Item has to be by Output Resolution
This commit is contained in:
parent
21c549e4ce
commit
8bf672e840
@ -54,8 +54,10 @@ public class Compare
|
||||
bool reverse = false;
|
||||
string outputExtension = ".jpg";
|
||||
PredictorModel? predictorModel = null;
|
||||
string peopleDateGroupDirectory = string.Empty;
|
||||
string zResultsFullGroupDirectory = string.Empty;
|
||||
Shared.Models.Person[] people = Array.Empty<Shared.Models.Person>();
|
||||
Map.Models.MapLogic mapLogic = new(_AppSettings.MaxDegreeOfParallelism, propertyConfiguration, outputExtension, people);
|
||||
Map.Models.MapLogic mapLogic = new(_AppSettings.MaxDegreeOfParallelism, propertyConfiguration, outputExtension, ticks, people, peopleDateGroupDirectory, zResultsFullGroupDirectory);
|
||||
A_Property propertyLogic = GetPropertyLogic(reverse, model, outputExtension, predictorModel, mapLogic);
|
||||
foreach (string spelling in configuration.Spelling)
|
||||
{
|
||||
|
@ -61,6 +61,8 @@ public class DlibDotNet
|
||||
_Distance = new E_Distance(configuration);
|
||||
if (configuration.IgnoreExtensions is null)
|
||||
throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||
string propertyRoot = Property.Models.Stateless.IResult.GetResultsGroupDirectory(propertyConfiguration, nameof(A_Property), create: false);
|
||||
_FirstRun = !Directory.Exists(propertyRoot);
|
||||
_Metadata = new(configuration.ForceMetadataLastWriteTimeToCreationTime, configuration.PropertiesChangedForMetadata);
|
||||
if (args.Count > 0)
|
||||
argZero = Path.GetFullPath(args[0]);
|
||||
@ -69,15 +71,6 @@ public class DlibDotNet
|
||||
_ArgZeroIsConfigurationRootDirectory = propertyConfiguration.RootDirectory == argZero;
|
||||
_Log.Information(configuration.ModelDirectory);
|
||||
(Model model, PredictorModel predictorModel, ModelParameter modelParameter) = GetModel(configuration);
|
||||
string propertyRoot = Property.Models.Stateless.IResult.GetResultsGroupDirectory(propertyConfiguration, nameof(A_Property), create: false);
|
||||
if (Directory.Exists(propertyRoot))
|
||||
_FirstRun = false;
|
||||
else
|
||||
{
|
||||
_FirstRun = true;
|
||||
string peopleDateGroupDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(propertyConfiguration, nameof(A2_People), "()");
|
||||
File.WriteAllText(Path.Combine(peopleDateGroupDirectory, "KnownPeople.txt"), string.Empty);
|
||||
}
|
||||
if (_FirstRun || !_ArgZeroIsConfigurationRootDirectory)
|
||||
people = Array.Empty<Person>();
|
||||
else
|
||||
@ -511,7 +504,7 @@ public class DlibDotNet
|
||||
}
|
||||
}
|
||||
|
||||
private (string, string, string, string, string, string, string) GetResultsFullGroupDirectories(Property.Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string outputResolution)
|
||||
private (string, string, string, string, string, string) GetResultsFullGroupDirectories(Property.Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string outputResolution)
|
||||
{
|
||||
string aResultsFullGroupDirectory = Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(
|
||||
configuration, model, predictorModel, nameof(A_Property), outputResolution, includeResizeGroup: false, includeModel: false, includePredictorModel: false);
|
||||
@ -525,9 +518,7 @@ public class DlibDotNet
|
||||
configuration, model, predictorModel, nameof(D2_FaceParts), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true);
|
||||
string eResultsFullGroupDirectory = Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(
|
||||
configuration, model, predictorModel, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true);
|
||||
string zResultsFullGroupDirectory = Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(
|
||||
configuration, model, predictorModel, $"Z_{nameof(Item)}", outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true);
|
||||
return new(aResultsFullGroupDirectory, bResultsFullGroupDirectory, cResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory, eResultsFullGroupDirectory, zResultsFullGroupDirectory);
|
||||
return new(aResultsFullGroupDirectory, bResultsFullGroupDirectory, cResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory, eResultsFullGroupDirectory);
|
||||
}
|
||||
|
||||
private void SetAngleBracketCollections(Property.Models.Configuration configuration, A_Property propertyLogic, string outputResolution, Container container, string aResultsFullGroupDirectory, string bResultsFullGroupDirectory, string cResultsFullGroupDirectory, string dResultsFullGroupDirectory)
|
||||
@ -580,7 +571,6 @@ public class DlibDotNet
|
||||
string cResultsFullGroupDirectory;
|
||||
string dResultsFullGroupDirectory;
|
||||
string eResultsFullGroupDirectory;
|
||||
string zResultsFullGroupDirectory;
|
||||
string d2ResultsFullGroupDirectory;
|
||||
List<List<Face>> faceCollections = new();
|
||||
Shared.Models.Property[] propertyCollection;
|
||||
@ -594,7 +584,7 @@ public class DlibDotNet
|
||||
{
|
||||
_FileKeyValuePairs.Clear();
|
||||
_FilePropertiesKeyValuePairs.Clear();
|
||||
(aResultsFullGroupDirectory, bResultsFullGroupDirectory, cResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory, eResultsFullGroupDirectory, zResultsFullGroupDirectory) = GetResultsFullGroupDirectories(configuration, model, predictorModel, outputResolution);
|
||||
(aResultsFullGroupDirectory, bResultsFullGroupDirectory, cResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory, eResultsFullGroupDirectory) = GetResultsFullGroupDirectories(configuration, model, predictorModel, outputResolution);
|
||||
foreach (Container container in containers)
|
||||
{
|
||||
if (!container.Items.Any())
|
||||
@ -687,49 +677,51 @@ public class DlibDotNet
|
||||
return results;
|
||||
}
|
||||
|
||||
private void MapLogic(string argZero, Container[] containers, long ticks, string dResultsFullGroupDirectory, string zResultsFullGroupDirectory, string d2ResultsFullGroupDirectory, MapLogic mapLogic, string outputResolution)
|
||||
private void MapLogic(string argZero, Container[] containers, long ticks, string dResultsFullGroupDirectory, string d2ResultsFullGroupDirectory, MapLogic mapLogic, string outputResolution)
|
||||
{
|
||||
string zPropertyHolderContentDirectory = Path.Combine(zResultsFullGroupDirectory, $"({ticks})");
|
||||
mapLogic.UseKeyValuePairsSaveFaceEncoding(containers);
|
||||
foreach (Container container in containers)
|
||||
{
|
||||
mapLogic.AddToMapping(container.Items);
|
||||
if (_Configuration.SaveShortcutsForOutputResolutions.Contains(outputResolution))
|
||||
mapLogic.SaveShortcuts(_Configuration.JuliePhares, zPropertyHolderContentDirectory, container.Items);
|
||||
mapLogic.SaveShortcuts(_Configuration.JuliePhares, container.Items);
|
||||
}
|
||||
mapLogic.SaveAllCollection();
|
||||
if (_Configuration.SaveResizedSubfiles)
|
||||
{
|
||||
string dFacesContentDirectory;
|
||||
string zPropertyHolderSingletonDirectory;
|
||||
string zPropertyHolderCollectionDirectory;
|
||||
dFacesContentDirectory = Path.Combine(dResultsFullGroupDirectory, "()");
|
||||
zPropertyHolderSingletonDirectory = Path.Combine(zResultsFullGroupDirectory, "{}");
|
||||
zPropertyHolderCollectionDirectory = Path.Combine(zResultsFullGroupDirectory, $"[{ticks}]");
|
||||
mapLogic.SaveNotMappedTicks(zPropertyHolderContentDirectory);
|
||||
mapLogic.SaveNotMappedTicks();
|
||||
_ = LogDeltaInMinutes(ticks, nameof(mapLogic.SaveNotMappedTicks));
|
||||
Dictionary<string, List<(FaceRecognitionDotNet.FaceEncoding, MappingContainer)>> keyValuePairs = _Distance.ParallelWork(_AppSettings.MaxDegreeOfParallelism, _Configuration.IgnoreRelativePaths, argZero, ticks, mapLogic, containers);
|
||||
_ = LogDeltaInSeconds(ticks, nameof(E_Distance.ParallelWork));
|
||||
Dictionary<int, List<MappingContainer>> strippedKeyValuePairs = Strip(keyValuePairs);
|
||||
List<(string, int, Mapping, DateTime, bool?, List<(FaceRecognitionDotNet.FaceEncoding, MappingContainer)>)> collection = Convert(keyValuePairs);
|
||||
mapLogic.SaveMapping(argZero, containers, dFacesContentDirectory, d2ResultsFullGroupDirectory, zPropertyHolderContentDirectory);
|
||||
mapLogic.SaveMapping(argZero, containers, dFacesContentDirectory, d2ResultsFullGroupDirectory);
|
||||
_ = LogDeltaInMinutes(ticks, nameof(mapLogic.SaveMapping));
|
||||
_Distance.AddToFaceDistance(_AppSettings.MaxDegreeOfParallelism, argZero, ticks, mapLogic, containers, outputResolution, collection);
|
||||
_ = LogDeltaInSeconds(ticks, nameof(_Distance.AddToFaceDistance));
|
||||
mapLogic.AddToClosest(_AppSettings.MaxDegreeOfParallelism, argZero, containers);
|
||||
_ = LogDeltaInMinutes(ticks, nameof(mapLogic.AddToClosest));
|
||||
mapLogic.SaveClosest(argZero, containers, dFacesContentDirectory, d2ResultsFullGroupDirectory, zPropertyHolderContentDirectory);
|
||||
mapLogic.SaveClosest(argZero, containers, dFacesContentDirectory, d2ResultsFullGroupDirectory);
|
||||
_ = LogDeltaInMinutes(ticks, nameof(mapLogic.SaveClosest));
|
||||
E_Distance.SavePropertyHolders(argZero, containers, zPropertyHolderSingletonDirectory);
|
||||
_ = LogDeltaInSeconds(ticks, nameof(E_Distance.SavePropertyHolders));
|
||||
mapLogic.SavePropertyHolders(argZero, containers);
|
||||
_ = LogDeltaInSeconds(ticks, nameof(mapLogic.SavePropertyHolders));
|
||||
}
|
||||
_ = LogDeltaInSeconds(ticks, nameof(MapLogic));
|
||||
}
|
||||
|
||||
private string GetMapLogicResultsFullGroupDirectory(Property.Models.Configuration configuration, Model? model, PredictorModel? predictorModel)
|
||||
{
|
||||
const int zero = 0;
|
||||
string outputResolution = _Configuration.OutputResolutions[zero];
|
||||
string zResultsFullGroupDirectory = Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(
|
||||
configuration, model, predictorModel, $"Z_{nameof(Item)}", outputResolution, includeResizeGroup: true, includeModel: false, includePredictorModel: false);
|
||||
return zResultsFullGroupDirectory;
|
||||
}
|
||||
|
||||
private void Search(Property.Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string argZero, string propertyRoot, Person[] people)
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new NullReferenceException(nameof(_Log));
|
||||
Container[] containers;
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
string aResultsFullGroupDirectory;
|
||||
@ -737,9 +729,10 @@ public class DlibDotNet
|
||||
string cResultsFullGroupDirectory;
|
||||
string dResultsFullGroupDirectory;
|
||||
string eResultsFullGroupDirectory;
|
||||
string zResultsFullGroupDirectory;
|
||||
string d2ResultsFullGroupDirectory;
|
||||
MapLogic mapLogic = new(_AppSettings.MaxDegreeOfParallelism, _Configuration.PropertyConfiguration, _Resize.FilenameExtension, _Faces.FilenameExtension, _Faces.HiddenFilenameExtension, _FaceParts.FilenameExtension, people);
|
||||
string zResultsFullGroupDirectory = GetMapLogicResultsFullGroupDirectory(configuration, model, predictorModel);
|
||||
string peopleDateGroupDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(A2_People));
|
||||
MapLogic mapLogic = new(_AppSettings.MaxDegreeOfParallelism, _Configuration.PropertyConfiguration, _Resize.FilenameExtension, _Faces.FilenameExtension, _Faces.HiddenFilenameExtension, _FaceParts.FilenameExtension, ticks, people, peopleDateGroupDirectory, zResultsFullGroupDirectory);
|
||||
A_Property propertyLogic = new(_AppSettings.MaxDegreeOfParallelism, _Configuration.PropertyConfiguration, _Resize.FilenameExtension, _Configuration.Reverse, model, predictorModel, mapLogic.IndicesFromNew, mapLogic.KeyValuePairs);
|
||||
if (string.IsNullOrEmpty(configuration.RootDirectory))
|
||||
containers = A_Property.Get(configuration, propertyLogic);
|
||||
@ -750,10 +743,10 @@ public class DlibDotNet
|
||||
{
|
||||
if (_FirstRun)
|
||||
break;
|
||||
(aResultsFullGroupDirectory, bResultsFullGroupDirectory, cResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory, eResultsFullGroupDirectory, zResultsFullGroupDirectory) = GetResultsFullGroupDirectories(configuration, model, predictorModel, outputResolution);
|
||||
(aResultsFullGroupDirectory, bResultsFullGroupDirectory, cResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory, eResultsFullGroupDirectory) = GetResultsFullGroupDirectories(configuration, model, predictorModel, outputResolution);
|
||||
if (_ArgZeroIsConfigurationRootDirectory && _Exceptions.Count == 0 && outputResolution == _Configuration.OutputResolutions[0])
|
||||
{
|
||||
MapLogic(argZero, containers, ticks, dResultsFullGroupDirectory, zResultsFullGroupDirectory, d2ResultsFullGroupDirectory, mapLogic, outputResolution);
|
||||
MapLogic(argZero, containers, ticks, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory, mapLogic, outputResolution);
|
||||
if (!_Configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions.Any())
|
||||
break;
|
||||
if (_FileKeyValuePairs.Any())
|
||||
|
@ -713,31 +713,4 @@ internal class E_Distance
|
||||
}
|
||||
}
|
||||
|
||||
public static void SavePropertyHolders(string argZero, Container[] containers, string zPropertyHolderSingletonDirectory)
|
||||
{
|
||||
string json;
|
||||
FileInfo fileInfo;
|
||||
bool updateDateWhenMatches = false;
|
||||
JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
|
||||
foreach (Container container in containers)
|
||||
{
|
||||
if (!container.Items.Any())
|
||||
continue;
|
||||
if (!container.SourceDirectory.StartsWith(argZero))
|
||||
continue;
|
||||
foreach (Item item in container.Items)
|
||||
{
|
||||
if (item.ImageFileHolder is null || item.Property is null || !item.Faces.Any() || !item.Closest.Any())
|
||||
continue;
|
||||
json = JsonSerializer.Serialize(item, jsonSerializerOptions);
|
||||
fileInfo = new(Path.GetFullPath(string.Concat(zPropertyHolderSingletonDirectory, item.RelativePath, ".json")));
|
||||
if (fileInfo.Directory is null)
|
||||
continue;
|
||||
if (!fileInfo.Directory.Exists)
|
||||
continue;
|
||||
_ = Shared.Models.Stateless.Methods.IPath.WriteAllText(fileInfo.FullName, json, updateDateWhenMatches, compareBeforeWrite: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -15,7 +15,6 @@ public class MapLogic
|
||||
protected readonly List<(int, string[])> _AllCollection;
|
||||
protected readonly Dictionary<int, int[]> _KeyValuePairs;
|
||||
protected readonly Dictionary<int, int[]> _IndicesFromNew;
|
||||
protected readonly string _DeterministicHashCodeContentDirectory;
|
||||
protected readonly Dictionary<int, string[]> _SixCharacterNamedFaceInfo;
|
||||
protected readonly Dictionary<double, PersonBirthday[]> _DeterministicHashCodeKeyValuePairs;
|
||||
protected readonly Dictionary<int, PersonBirthday[]> _DeterministicHashCodeUnknownFaceKeyValuePairs;
|
||||
@ -25,15 +24,20 @@ public class MapLogic
|
||||
public Dictionary<int, int[]> KeyValuePairs => _KeyValuePairs;
|
||||
public Dictionary<int, int[]> IndicesFromNew => _IndicesFromNew;
|
||||
|
||||
private readonly long _Ticks;
|
||||
private readonly Serilog.ILogger? _Log;
|
||||
private readonly Configuration _Configuration;
|
||||
private readonly string _FacesFilenameExtension;
|
||||
private readonly string _ResizeFilenameExtension;
|
||||
private readonly string _FacePartsFilenameExtension;
|
||||
private readonly string _FacesHiddenFilenameExtension;
|
||||
private readonly string _ZPropertyHolderContentDirectory;
|
||||
private readonly string _ZPropertyHolderContentTicksDirectory;
|
||||
private readonly string _ZPropertyHolderSingletonTicksDirectory;
|
||||
|
||||
public MapLogic(int maxDegreeOfParallelism, Configuration configuration, string resizeFilenameExtension, string facesFilenameExtension, string facesHiddenFilenameExtension, string facePartsFilenameExtension, Person[] people)
|
||||
public MapLogic(int maxDegreeOfParallelism, Configuration configuration, string resizeFilenameExtension, string facesFilenameExtension, string facesHiddenFilenameExtension, string facePartsFilenameExtension, long ticks, Person[] people, string peopleDateGroupDirectory, string zResultsFullGroupDirectory)
|
||||
{
|
||||
_Ticks = ticks;
|
||||
_AllCollection = new();
|
||||
_Configuration = configuration;
|
||||
_Log = Serilog.Log.ForContext<MapLogic>();
|
||||
@ -47,32 +51,39 @@ public class MapLogic
|
||||
string json;
|
||||
string[] files;
|
||||
string fullPath;
|
||||
List<long> notMappedTicks = new();
|
||||
List<double> skipCollection = new();
|
||||
Dictionary<int, int[]>? keyValuePairs;
|
||||
List<long> notMappedTicks = new();
|
||||
List<KeyValuePair<int, int[]>>? collection;
|
||||
string deterministicHashCodeContentDirectory;
|
||||
Dictionary<int, int[]> indicesFromNew = new();
|
||||
;
|
||||
Dictionary<int, string[]>? sixCharacterNamedFaceInfo;
|
||||
Dictionary<double, PersonBirthday[]> deterministicHashCodeKeyValuePairs = new();
|
||||
string? rootDirectoryParent = Path.GetDirectoryName(configuration.RootDirectory);
|
||||
Dictionary<long, (string, int?, PersonBirthday[], long)> peopleKeyValuePairs = new();
|
||||
string zPropertyHolderContentDirectory = Path.Combine(zResultsFullGroupDirectory, "()");
|
||||
Dictionary<double, PersonBirthday[]> incorrectDeterministicHashCodeKeyValuePairs = new();
|
||||
string zPropertyHolderSingletonDirectory = Path.Combine(zResultsFullGroupDirectory, "{}");
|
||||
string zPropertyHolderContentTicksDirectory = Path.Combine(zPropertyHolderContentDirectory, $"({ticks})");
|
||||
string zPropertyHolderPeopleContentDirectory = Path.Combine(peopleDateGroupDirectory, "()", "(KnownPeople)");
|
||||
string zPropertyHolderSingletonTicksDirectory = Path.Combine(zPropertyHolderSingletonDirectory, string.Concat('{', _Ticks, '}'));
|
||||
if (string.IsNullOrEmpty(rootDirectoryParent))
|
||||
throw new NullReferenceException(nameof(rootDirectoryParent));
|
||||
string deterministicHashCodeRootDirectory = Path.Combine(rootDirectoryParent, "DeterministicHashCode");
|
||||
if (!Directory.Exists(zPropertyHolderContentDirectory))
|
||||
_ = Directory.CreateDirectory(zPropertyHolderContentDirectory);
|
||||
if (!Directory.Exists(zPropertyHolderPeopleContentDirectory))
|
||||
_ = Directory.CreateDirectory(zPropertyHolderPeopleContentDirectory);
|
||||
files = Directory.GetFiles(rootDirectoryParent, "DeterministicHashCode*.json", SearchOption.TopDirectoryOnly);
|
||||
if (files.Length != 1)
|
||||
deterministicHashCodeUnknownFaceKeyValuePairs = new();
|
||||
else
|
||||
{
|
||||
json = File.ReadAllText(files[0]);
|
||||
deterministicHashCodeUnknownFaceKeyValuePairs = Get(json);
|
||||
deterministicHashCodeUnknownFaceKeyValuePairs = GetKeyValuePairs(json);
|
||||
}
|
||||
if (!Directory.Exists(deterministicHashCodeRootDirectory))
|
||||
_ = Directory.CreateDirectory(deterministicHashCodeRootDirectory);
|
||||
deterministicHashCodeContentDirectory = Path.Combine(deterministicHashCodeRootDirectory, "()");
|
||||
Stateless.ByDeterministicHashCode.SetByRef(_ResizeFilenameExtension, people, skipCollection, peopleKeyValuePairs, notMappedTicks, deterministicHashCodeUnknownFaceKeyValuePairs, deterministicHashCodeKeyValuePairs, incorrectDeterministicHashCodeKeyValuePairs, deterministicHashCodeRootDirectory, deterministicHashCodeContentDirectory);
|
||||
Stateless.ByDeterministicHashCode.SetByRef(_ResizeFilenameExtension, people, skipCollection, peopleKeyValuePairs, notMappedTicks, deterministicHashCodeUnknownFaceKeyValuePairs, deterministicHashCodeKeyValuePairs, incorrectDeterministicHashCodeKeyValuePairs, zPropertyHolderContentDirectory, zPropertyHolderPeopleContentDirectory);
|
||||
if (!Directory.Exists(zPropertyHolderContentTicksDirectory))
|
||||
_ = Directory.CreateDirectory(zPropertyHolderContentTicksDirectory);
|
||||
if (!deterministicHashCodeUnknownFaceKeyValuePairs.Any())
|
||||
sixCharacterNamedFaceInfo = new();
|
||||
else
|
||||
@ -122,19 +133,21 @@ public class MapLogic
|
||||
_NotMappedTicks = notMappedTicks;
|
||||
_PeopleKeyValuePairs = peopleKeyValuePairs;
|
||||
_SixCharacterNamedFaceInfo = sixCharacterNamedFaceInfo;
|
||||
_ZPropertyHolderContentDirectory = zPropertyHolderContentDirectory;
|
||||
_DeterministicHashCodeKeyValuePairs = deterministicHashCodeKeyValuePairs;
|
||||
_DeterministicHashCodeContentDirectory = deterministicHashCodeContentDirectory;
|
||||
_ZPropertyHolderContentTicksDirectory = zPropertyHolderContentTicksDirectory;
|
||||
_ZPropertyHolderSingletonTicksDirectory = zPropertyHolderSingletonTicksDirectory;
|
||||
_IncorrectDeterministicHashCodeKeyValuePairs = incorrectDeterministicHashCodeKeyValuePairs;
|
||||
_DeterministicHashCodeUnknownFaceKeyValuePairs = deterministicHashCodeUnknownFaceKeyValuePairs;
|
||||
}
|
||||
|
||||
public MapLogic(int maxDegreeOfParallelism, Configuration configuration, string outputExtension, Person[] people) :
|
||||
this(maxDegreeOfParallelism, configuration, outputExtension, outputExtension, outputExtension, outputExtension, people)
|
||||
public MapLogic(int maxDegreeOfParallelism, Configuration configuration, string outputExtension, long ticks, Person[] people, string peopleDateGroupDirectory, string zResultsFullGroupDirectory) :
|
||||
this(maxDegreeOfParallelism, configuration, outputExtension, outputExtension, outputExtension, outputExtension, ticks, people, peopleDateGroupDirectory, zResultsFullGroupDirectory)
|
||||
{ }
|
||||
|
||||
public bool Skip(double deterministicHashCodeKey) => _SkipCollection.Contains(deterministicHashCodeKey);
|
||||
|
||||
private static Dictionary<int, PersonBirthday[]> Get(string json)
|
||||
private static Dictionary<int, PersonBirthday[]> GetKeyValuePairs(string json)
|
||||
{
|
||||
Dictionary<int, PersonBirthday[]> results = new();
|
||||
PersonBirthday? personBirthday;
|
||||
@ -158,7 +171,7 @@ public class MapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
public void SaveShortcuts(string[] juliePhares, string zPropertyHolderContentDirectory, List<Item> items)
|
||||
public void SaveShortcuts(string[] juliePhares, List<Item> items)
|
||||
{
|
||||
string fileName;
|
||||
string fullName;
|
||||
@ -167,7 +180,7 @@ public class MapLogic
|
||||
PersonBirthday personBirthday;
|
||||
WindowsShortcut windowsShortcut;
|
||||
(string DisplayDirectoryName, int? ApproximateYears, PersonBirthday[] _, long Ticks) person;
|
||||
List<(Item, (long?, Face?, (string, string, string, string))[])> collections = GetCollection(items, zPropertyHolderContentDirectory);
|
||||
List<(Item, (long?, Face?, (string, string, string, string))[])> collections = GetCollection(items);
|
||||
foreach ((Item item, (long? ticks, Face? _, (string, string, string, string))[] collection) in collections)
|
||||
{
|
||||
if (collection.Length != 1)
|
||||
@ -216,28 +229,26 @@ public class MapLogic
|
||||
|
||||
public void UseKeyValuePairsSaveFaceEncoding(Container[] containers)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_DeterministicHashCodeContentDirectory))
|
||||
Dictionary<int, List<Face>> keyValuePairs = new();
|
||||
List<(PersonBirthday PersonBirthday, double IdAndNormalizedPixelPercentage)> deterministicHashCodeCollection = new();
|
||||
List<(PersonBirthday PersonBirthday, double IdAndNormalizedPixelPercentage)> incorrectDeterministicHashCodeCollection = new();
|
||||
foreach (Container container in containers)
|
||||
{
|
||||
Dictionary<int, List<Face>> keyValuePairs = new();
|
||||
List<(PersonBirthday PersonBirthday, double IdAndNormalizedPixelPercentage)> deterministicHashCodeCollection = new();
|
||||
List<(PersonBirthday PersonBirthday, double IdAndNormalizedPixelPercentage)> incorrectDeterministicHashCodeCollection = new();
|
||||
foreach (Container container in containers)
|
||||
foreach (Item item in container.Items)
|
||||
{
|
||||
foreach (Item item in container.Items)
|
||||
if (item.ImageFileHolder is null || item.Property?.Id is null || !item.Faces.Any())
|
||||
continue;
|
||||
if (keyValuePairs.ContainsKey(item.Property.Id.Value))
|
||||
{
|
||||
if (item.ImageFileHolder is null || item.Property?.Id is null || !item.Faces.Any())
|
||||
continue;
|
||||
if (keyValuePairs.ContainsKey(item.Property.Id.Value))
|
||||
{
|
||||
if (keyValuePairs[item.Property.Id.Value].Count != item.Faces.Count)
|
||||
throw new Exception();
|
||||
continue;
|
||||
}
|
||||
keyValuePairs.Add(item.Property.Id.Value, item.Faces);
|
||||
if (keyValuePairs[item.Property.Id.Value].Count != item.Faces.Count)
|
||||
throw new Exception();
|
||||
continue;
|
||||
}
|
||||
keyValuePairs.Add(item.Property.Id.Value, item.Faces);
|
||||
}
|
||||
Stateless.ByDeterministicHashCode.SetKeyValuePairs(_DeterministicHashCodeContentDirectory, deterministicHashCodeCollection, incorrectDeterministicHashCodeCollection, keyValuePairs);
|
||||
}
|
||||
Stateless.ByDeterministicHashCode.SetKeyValuePairs(_ZPropertyHolderContentDirectory, deterministicHashCodeCollection, incorrectDeterministicHashCodeCollection, keyValuePairs);
|
||||
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@ -419,7 +430,7 @@ public class MapLogic
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveNotMappedTicks(string zPropertyHolderContentDirectory)
|
||||
public void SaveNotMappedTicks()
|
||||
{
|
||||
string directory;
|
||||
string personKey;
|
||||
@ -431,14 +442,14 @@ public class MapLogic
|
||||
{
|
||||
personBirthday = Shared.Models.Stateless.Methods.IPersonBirthday.GetPersonBirthday(ticks);
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(personBirthday);
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}NotMapped", personKey, Property.Models.Stateless.IResult.AllInOne);
|
||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"{facePopulatedKey}NotMapped", personKey, Property.Models.Stateless.IResult.AllInOne);
|
||||
saveContainer = new(directory);
|
||||
saveContainers.Add(saveContainer);
|
||||
}
|
||||
SaveContainers(saveContainers);
|
||||
}
|
||||
|
||||
public List<(Item, (long?, Face?, (string, string, string, string))[])> GetCollection(List<Item> items, string zPropertyHolderContentDirectory)
|
||||
public List<(Item, (long?, Face?, (string, string, string, string))[])> GetCollection(List<Item> items)
|
||||
{
|
||||
List<(Item, (long?, Face?, (string, string, string, string))[])> results = new();
|
||||
int years;
|
||||
@ -481,7 +492,7 @@ public class MapLogic
|
||||
{
|
||||
faceCollection = new();
|
||||
ticks = null;
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"Unnamed{relativePath[2..]}");
|
||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"Unnamed{relativePath[2..]}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -494,17 +505,17 @@ public class MapLogic
|
||||
if (!faceCollection.Any())
|
||||
{
|
||||
ticks = null;
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"None{relativePath[2..]}", subDirectoryName);
|
||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"None{relativePath[2..]}", subDirectoryName);
|
||||
}
|
||||
else if (personBirthdays.Length != 1)
|
||||
{
|
||||
ticks = null;
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"Not Supported{relativePath[2..]}", subDirectoryName);
|
||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"Not Supported{relativePath[2..]}", subDirectoryName);
|
||||
}
|
||||
else if (faceCollection.Count != 1)
|
||||
{
|
||||
ticks = null;
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"Many{relativePath[2..]}", subDirectoryName);
|
||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"Many{relativePath[2..]}", subDirectoryName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -524,11 +535,11 @@ public class MapLogic
|
||||
}
|
||||
face = faceCollection[zero];
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(personBirthday);
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, "Shortcuts", personKey, subDirectoryName);
|
||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, "Shortcuts", personKey, subDirectoryName);
|
||||
if (face.FaceEncoding is not null && face.Location?.NormalizedPixelPercentage is not null)
|
||||
copyDirectory = Path.Combine(zPropertyHolderContentDirectory, "Images", personKey, subDirectoryName);
|
||||
copyDirectory = Path.Combine(_ZPropertyHolderContentTicksDirectory, "Images", personKey, subDirectoryName);
|
||||
else
|
||||
copyDirectory = Path.Combine(zPropertyHolderContentDirectory, "ImagesBut", personKey, subDirectoryName);
|
||||
copyDirectory = Path.Combine(_ZPropertyHolderContentTicksDirectory, "ImagesBut", personKey, subDirectoryName);
|
||||
copyFileName = Path.Combine(copyDirectory, $"{item.Property.Id.Value}{item.ResizedFileHolder.ExtensionLowered}");
|
||||
}
|
||||
}
|
||||
@ -597,7 +608,7 @@ public class MapLogic
|
||||
}
|
||||
}
|
||||
|
||||
private List<SaveContainer> GetMappingSaveContainers(string argZero, Container[] containers, string dFacesContentDirectory, string d2ResultsFullGroupDirectory, string zPropertyHolderContentDirectory)
|
||||
private List<SaveContainer> GetMappingSaveContainers(string argZero, Container[] containers, string dFacesContentDirectory, string d2ResultsFullGroupDirectory)
|
||||
{
|
||||
List<SaveContainer> results = new();
|
||||
string key;
|
||||
@ -665,11 +676,11 @@ public class MapLogic
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(match.PersonBirthday);
|
||||
key = string.Concat(personKey, dateKey);
|
||||
if (match.Filtered is null)
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}Null", personKey, dateKey);
|
||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"{facePopulatedKey}Null", personKey, dateKey);
|
||||
else if (!match.Filtered.Value)
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}Okay", personKey, dateKey);
|
||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"{facePopulatedKey}Okay", personKey, dateKey);
|
||||
else
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}OutOfControl", personKey, dateKey);
|
||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"{facePopulatedKey}OutOfControl", personKey, dateKey);
|
||||
personDirectory = Path.Combine(directory, match.DisplayDirectoryName[..1], "lnk");
|
||||
saveContainer = new(personDirectory);
|
||||
results.Add(saveContainer);
|
||||
@ -731,11 +742,11 @@ public class MapLogic
|
||||
(isWrongYear, _) = item.Property.IsWrongYear(item.ImageFileHolder.FullName, minimumDateTime);
|
||||
dateKey = Stateless.MapLogic.GetDateKey(dateTime, match, minimumDateTime, isWrongYear);
|
||||
if (match.Filtered is null)
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}WithButNull", personKey, dateKey);
|
||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"{facePopulatedKey}WithButNull", personKey, dateKey);
|
||||
else if (!match.Filtered.Value)
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}WithAndOkay", personKey, dateKey);
|
||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"{facePopulatedKey}WithAndOkay", personKey, dateKey);
|
||||
else
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}WithButOutOfControl", personKey, dateKey);
|
||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"{facePopulatedKey}WithButOutOfControl", personKey, dateKey);
|
||||
personDirectory = Path.Combine(directory, match.DisplayDirectoryName[..1], "lnk");
|
||||
saveContainer = new(personDirectory);
|
||||
results.Add(saveContainer);
|
||||
@ -770,7 +781,7 @@ public class MapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
private List<SaveContainer> GetClosestSaveContainers(string argZero, Container[] containers, string dFacesContentDirectory, string d2ResultsFullGroupDirectory, string zPropertyHolderContentDirectory)
|
||||
private List<SaveContainer> GetClosestSaveContainers(string argZero, Container[] containers, string dFacesContentDirectory, string d2ResultsFullGroupDirectory)
|
||||
{
|
||||
List<SaveContainer> results = new();
|
||||
Closest? match;
|
||||
@ -847,7 +858,7 @@ public class MapLogic
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(match.Mapping.PersonBirthday);
|
||||
}
|
||||
dateKey = Stateless.MapLogic.GetDateKey(dateTime, match.Mapping, match.MinimumDateTime, match.IsWrongYear);
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, facePopulatedKey, personKey, dateKey);
|
||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, facePopulatedKey, personKey, dateKey);
|
||||
personDirectory = Path.Combine(directory, match.Mapping.DisplayDirectoryName[..1], "lnk");
|
||||
saveContainer = new(personDirectory);
|
||||
results.Add(saveContainer);
|
||||
@ -875,7 +886,7 @@ public class MapLogic
|
||||
continue;
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(closest.Mapping.PersonBirthday);
|
||||
dateKey = Stateless.MapLogic.GetDateKey(dateTime, closest.Mapping, closest.MinimumDateTime, closest.IsWrongYear);
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, facePopulatedKey, personKey, dateKey);
|
||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, facePopulatedKey, personKey, dateKey);
|
||||
personDirectory = Path.Combine(directory, closest.Mapping.DisplayDirectoryName, "lnk");
|
||||
saveContainer = new(personDirectory);
|
||||
results.Add(saveContainer);
|
||||
@ -902,15 +913,15 @@ public class MapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
public void SaveMapping(string argZero, Container[] containers, string dFacesContentDirectory, string d2ResultsFullGroupDirectory, string zPropertyHolderContentDirectory)
|
||||
public void SaveMapping(string argZero, Container[] containers, string dFacesContentDirectory, string d2ResultsFullGroupDirectory)
|
||||
{
|
||||
List<SaveContainer> saveContainers = GetMappingSaveContainers(argZero, containers, dFacesContentDirectory, d2ResultsFullGroupDirectory, zPropertyHolderContentDirectory);
|
||||
List<SaveContainer> saveContainers = GetMappingSaveContainers(argZero, containers, dFacesContentDirectory, d2ResultsFullGroupDirectory);
|
||||
SaveContainers(saveContainers);
|
||||
}
|
||||
|
||||
public void SaveClosest(string argZero, Container[] containers, string dFacesContentDirectory, string d2ResultsFullGroupDirectory, string zPropertyHolderContentDirectory)
|
||||
public void SaveClosest(string argZero, Container[] containers, string dFacesContentDirectory, string d2ResultsFullGroupDirectory)
|
||||
{
|
||||
List<SaveContainer> saveContainers = GetClosestSaveContainers(argZero, containers, dFacesContentDirectory, d2ResultsFullGroupDirectory, zPropertyHolderContentDirectory);
|
||||
List<SaveContainer> saveContainers = GetClosestSaveContainers(argZero, containers, dFacesContentDirectory, d2ResultsFullGroupDirectory);
|
||||
SaveContainers(saveContainers);
|
||||
}
|
||||
|
||||
@ -964,4 +975,31 @@ public class MapLogic
|
||||
}
|
||||
}
|
||||
|
||||
public void SavePropertyHolders(string argZero, Container[] containers)
|
||||
{
|
||||
string json;
|
||||
FileInfo fileInfo;
|
||||
bool updateDateWhenMatches = false;
|
||||
JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
|
||||
foreach (Container container in containers)
|
||||
{
|
||||
if (!container.Items.Any())
|
||||
continue;
|
||||
if (!container.SourceDirectory.StartsWith(argZero))
|
||||
continue;
|
||||
foreach (Item item in container.Items)
|
||||
{
|
||||
if (item.ImageFileHolder is null || item.Property is null || !item.Faces.Any() || !item.Closest.Any())
|
||||
continue;
|
||||
json = JsonSerializer.Serialize(item, jsonSerializerOptions);
|
||||
fileInfo = new(Path.GetFullPath(string.Concat(_ZPropertyHolderSingletonTicksDirectory, item.RelativePath, ".json")));
|
||||
if (fileInfo.Directory is null)
|
||||
continue;
|
||||
if (!fileInfo.Directory.Exists)
|
||||
continue;
|
||||
_ = Shared.Models.Stateless.Methods.IPath.WriteAllText(fileInfo.FullName, json, updateDateWhenMatches, compareBeforeWrite: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -124,7 +124,7 @@ public class ByDeterministicHashCode
|
||||
}
|
||||
}
|
||||
|
||||
internal static void SetKeyValuePairs(string deterministicHashCodeContentDirectory, List<(PersonBirthday, double)> deterministicHashCodeCollection, List<(PersonBirthday, double)> incorrectDeterministicHashCodeCollection, Dictionary<int, List<Face>> keyValuePairs)
|
||||
internal static void SetKeyValuePairs(string zPropertyHolderContentDirectory, List<(PersonBirthday, double)> deterministicHashCodeCollection, List<(PersonBirthday, double)> incorrectDeterministicHashCodeCollection, Dictionary<int, List<Face>> keyValuePairs)
|
||||
{
|
||||
string[] files;
|
||||
string personKey;
|
||||
@ -138,7 +138,7 @@ public class ByDeterministicHashCode
|
||||
string? personFirstInitialDirectory;
|
||||
double? reversedDeterministicHashCodeKey;
|
||||
bool keyValuePairsAny = keyValuePairs.Any();
|
||||
string[] ticksDirectories = Directory.GetDirectories(deterministicHashCodeContentDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
string[] ticksDirectories = Directory.GetDirectories(zPropertyHolderContentDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
foreach (string ticksDirectory in ticksDirectories)
|
||||
{
|
||||
ticksDirectoryName = Path.GetFileName(ticksDirectory);
|
||||
@ -231,24 +231,18 @@ public class ByDeterministicHashCode
|
||||
}
|
||||
}
|
||||
|
||||
internal static void SetByRef(string resizeFilenameExtension, Person[] people, List<double> skipCollection, Dictionary<long, (string, int?, PersonBirthday[], long)> peopleKeyValuePairs, List<long> notMappedTicks, Dictionary<int, PersonBirthday[]> deterministicHashCodeUnknownFaceKeyValuePairs, Dictionary<double, PersonBirthday[]> deterministicHashCodeKeyValuePairs, Dictionary<double, PersonBirthday[]> incorrectDeterministicHashCodeKeyValuePairs, string deterministicHashCodeRootDirectory, string deterministicHashCodeContentDirectory)
|
||||
internal static void SetByRef(string resizeFilenameExtension, Person[] people, List<double> skipCollection, Dictionary<long, (string, int?, PersonBirthday[], long)> peopleKeyValuePairs, List<long> notMappedTicks, Dictionary<int, PersonBirthday[]> deterministicHashCodeUnknownFaceKeyValuePairs, Dictionary<double, PersonBirthday[]> deterministicHashCodeKeyValuePairs, Dictionary<double, PersonBirthday[]> incorrectDeterministicHashCodeKeyValuePairs, string zPropertyHolderContentDirectory, string zPropertyHolderPeopleContentDirectory)
|
||||
{
|
||||
Dictionary<int, List<Face>> keyValuePairs = new();
|
||||
List<long> deterministicHashCodePersonKeys = new();
|
||||
List<(string, int?, PersonBirthday[], long)> peopleCollection = new();
|
||||
Dictionary<double, List<PersonBirthday>> deterministicHashCodeScope = new();
|
||||
Dictionary<double, List<PersonBirthday>> incorrectDeterministicHashCodeScope = new();
|
||||
string deterministicHashCodePeopleDirectory = Path.Combine(deterministicHashCodeRootDirectory, "People");
|
||||
List<long> deterministicHashCodeUnknownFacePersonKeys = GetTicks(deterministicHashCodeUnknownFaceKeyValuePairs);
|
||||
List<(PersonBirthday PersonBirthday, double IdAndNormalizedPixelPercentage)> incorrectDeterministicHashCodeCollection = new();
|
||||
List<(PersonBirthday PersonBirthday, double IdAndNormalizedPixelPercentage)> deterministicHashCodeCollection = new();
|
||||
if (!Directory.Exists(deterministicHashCodePeopleDirectory))
|
||||
_ = Directory.CreateDirectory(deterministicHashCodePeopleDirectory);
|
||||
else
|
||||
SetOther(resizeFilenameExtension, people, deterministicHashCodePeopleDirectory, skipCollection, peopleCollection);
|
||||
if (!Directory.Exists(deterministicHashCodeContentDirectory))
|
||||
_ = Directory.CreateDirectory(deterministicHashCodeContentDirectory);
|
||||
SetKeyValuePairs(deterministicHashCodeContentDirectory, deterministicHashCodeCollection, incorrectDeterministicHashCodeCollection, keyValuePairs);
|
||||
SetOther(resizeFilenameExtension, people, zPropertyHolderPeopleContentDirectory, skipCollection, peopleCollection);
|
||||
SetKeyValuePairs(zPropertyHolderContentDirectory, deterministicHashCodeCollection, incorrectDeterministicHashCodeCollection, keyValuePairs);
|
||||
Set(deterministicHashCodeCollection, deterministicHashCodePersonKeys, deterministicHashCodeScope);
|
||||
incorrectDeterministicHashCodeCollection = (from l in incorrectDeterministicHashCodeCollection orderby l.IdAndNormalizedPixelPercentage select l).ToList();
|
||||
deterministicHashCodePersonKeys = deterministicHashCodePersonKeys.Distinct().ToList();
|
||||
|
Loading…
x
Reference in New Issue
Block a user