Instance UserSecretsId and BlurHash for 1376 x 768

This commit is contained in:
2023-06-12 11:27:58 -07:00
parent 085dee358c
commit 1712de2952
20 changed files with 191 additions and 556 deletions

View File

@ -349,6 +349,28 @@ public partial class DlibDotNet
return result;
}
private void LogItemPropertyIsNull(Item item)
{
if (_Log is null)
throw new NullReferenceException(nameof(_Log));
if (!item.SourceDirectoryFileHolder.Exists)
_Log.Information(string.Concat("NoJson <", item.ImageFileHolder.FullName, '>'));
else if (item.FileSizeChanged.HasValue && item.FileSizeChanged.Value)
_Log.Information(string.Concat("FileSizeChanged <", item.ImageFileHolder.FullName, '>'));
else if (item.LastWriteTimeChanged.HasValue && item.LastWriteTimeChanged.Value)
_Log.Information(string.Concat("LastWriteTimeChanged <", item.ImageFileHolder.FullName, '>'));
else if (item.Moved.HasValue && item.Moved.Value)
_Log.Information(string.Concat("Moved <", item.ImageFileHolder.FullName, '>'));
}
private void LogNameWithoutExtensionIsIdFormatBut(Item item)
{
if (_Log is null)
throw new NullReferenceException(nameof(_Log));
_Log.Information($"Name without extension is Id format but doesn't match id <{item.ImageFileHolder.FullName}>");
File.Move(item.ImageFileHolder.FullName, $"{item.ImageFileHolder.FullName}.rename");
}
private void FullParallelForWork(A_Property propertyLogic,
B_Metadata metadata,
ReadOnlyDictionary<int, List<LocationContainer<MetadataExtractor.Directory>>> idToLocationContainers,
@ -366,8 +388,6 @@ public partial class DlibDotNet
bool? isIgnoreRelativePath,
string facePartsCollectionDirectory)
{
if (_Log is null)
throw new NullReferenceException(nameof(_Log));
List<Shared.Models.Face> faces;
long ticks = DateTime.Now.Ticks;
DateTime dateTime = DateTime.Now;
@ -376,56 +396,10 @@ public partial class DlibDotNet
List<Tuple<string, DateTime>> subFileTuples = new();
List<KeyValuePair<string, string>> metadataCollection;
FileHolder resizedFileHolder = _Resize.GetResizedFileHolder(item);
if (item.Property is not null && item.Property.Id is not null && resizedFileHolder.Exists && item.Property.Width is not null && item.Property.Height is not null)
{
_ = _BlurHasher?.EncodeAndSave(resizedFileHolder);
// if (item.Property.Width.Value < -255 && item.Property.Height.Value < -255)
// {
// MemoryStream memoryStream = _ThumbHasher.GetMemoryStream(Array.Empty<byte>(), item.Property.Width.Value, item.Property.Height.Value);
// string thumbHashJson = JsonSerializer.Serialize(Array.Empty<byte>())[1..^1];
// if (!Regex.Matches(thumbHashJson, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]").Any())
// fileName = Path.Combine(c2HasherSingletonDirectory, $"{thumbHashJson}.png");
// else
// {
// // string thumbHash = BitConverter.ToString(Array.Empty<byte>()).Replace("-", string.Empty);
// // fileName = Path.Combine(c2HasherContentDirectory, $"{thumbHash}.png");
// fileName = Path.Combine(c2HasherContentDirectory, $"{resizedFileHolder.NameWithoutExtension}.png");
// }
// if (!File.Exists(fileName))
// {
// using FileStream fileStream = new(fileName, FileMode.CreateNew);
// memoryStream.WriteTo(fileStream);
// memoryStream.Dispose();
// if (resizedFileHolder.LastWriteTime is not null)
// File.SetLastWriteTime(fileName, resizedFileHolder.LastWriteTime.Value);
// }
// }
}
if (item.Property is not null && item.Property.Id is not null && !item.Any())
{
property = item.Property;
if (item.SourceDirectoryFileHolder.LastWriteTime is not null)
subFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), item.SourceDirectoryFileHolder.LastWriteTime.Value));
else
subFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), new FileInfo(item.SourceDirectoryFileHolder.FullName).LastWriteTime));
bool nameWithoutExtensionIsIdFormat = Shared.Models.Stateless.Methods.IProperty.NameWithoutExtensionIsIdFormat(item.ImageFileHolder);
if (nameWithoutExtensionIsIdFormat && item.ImageFileHolder.NameWithoutExtension != item.Property.Id.ToString())
{
_Log.Information($"Name without extension is Id format but doesn't match id <{item.ImageFileHolder.FullName}>");
File.Move(item.ImageFileHolder.FullName, $"{item.ImageFileHolder.FullName}.rename");
}
}
else
if (item.Property is null || item.Property.Id is null || item.Any())
{
LogItemPropertyIsNull(item);
int? propertyHashCode = item.Property?.GetHashCode();
if (!item.SourceDirectoryFileHolder.Exists)
_Log.Information(string.Concat("NoJson <", item.ImageFileHolder.FullName, '>'));
else if (item.FileSizeChanged.HasValue && item.FileSizeChanged.Value)
_Log.Information(string.Concat("FileSizeChanged <", item.ImageFileHolder.FullName, '>'));
else if (item.LastWriteTimeChanged.HasValue && item.LastWriteTimeChanged.Value)
_Log.Information(string.Concat("LastWriteTimeChanged <", item.ImageFileHolder.FullName, '>'));
else if (item.Moved.HasValue && item.Moved.Value)
_Log.Information(string.Concat("Moved <", item.ImageFileHolder.FullName, '>'));
property = propertyLogic.GetProperty(item, subFileTuples, parseExceptions);
item.Update(property);
if (propertyHashCode is null)
@ -439,6 +413,23 @@ public partial class DlibDotNet
sourceDirectoryChanges.Add(new Tuple<string, DateTime>(nameof(A_Property), DateTime.Now));
}
}
else
{
property = item.Property;
if (item.SourceDirectoryFileHolder.LastWriteTime is not null)
subFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), item.SourceDirectoryFileHolder.LastWriteTime.Value));
else
subFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), new FileInfo(item.SourceDirectoryFileHolder.FullName).LastWriteTime));
bool nameWithoutExtensionIsIdFormat = Shared.Models.Stateless.Methods.IProperty.NameWithoutExtensionIsIdFormat(item.ImageFileHolder);
if (nameWithoutExtensionIsIdFormat && item.ImageFileHolder.NameWithoutExtension != item.Property.Id.ToString())
LogNameWithoutExtensionIsIdFormatBut(item);
if (_BlurHasher is not null && resizedFileHolder.Exists && item.Property.Width is not null && item.Property.Width.Value > 4 && _Configuration.SaveBlurHashForOutputResolutions.Contains(outputResolution))
{
string? file = _BlurHasher.GetFile(resizedFileHolder);
if (file is not null && !File.Exists(file))
_ = _BlurHasher.EncodeAndSave(resizedFileHolder);
}
}
if (property is null || item.Property is null)
throw new NullReferenceException(nameof(property));
item.SetResizedFileHolder(_Resize.FileNameExtension, resizedFileHolder);

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>10.0</LangVersion>
@ -6,7 +6,8 @@
<OutputType>Exe</OutputType>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<UserSecretsId>2999dda1-5329-4d9f-9d68-cccfabe0e47f</UserSecretsId>
</PropertyGroup>
<PropertyGroup>
<PackageId>Phares.View.by.Distance.Instance</PackageId>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>

View File

@ -68,7 +68,8 @@ public class Configuration
[Display(Name = "Face Area Permille Tolerance"), Required] public float[] RangeFaceAreaTolerance { get; set; }
[Display(Name = "Location Minimum Confidence"), Required] public float[] RangeFaceConfidence { get; set; }
[Display(Name = "Reverse"), Required] public bool? Reverse { get; set; }
[Display(Name = "Save Face Distances"), Required] public string[] SaveFaceDistancesForOutputResolutions { get; set; }
[Display(Name = "Save Blur Hash For Output Resolutions"), Required] public string[] SaveBlurHashForOutputResolutions { get; set; }
[Display(Name = "Save Face Distances For Output Resolutions"), Required] public string[] SaveFaceDistancesForOutputResolutions { get; set; }
[Display(Name = "Save Face Landmark For Output Resolutions"), Required] public string[] SaveFaceLandmarkForOutputResolutions { get; set; }
[Display(Name = "Save Full Year Of Random Files"), Required] public bool? SaveFullYearOfRandomFiles { get; set; }
[Display(Name = "Save Mapped"), Required] public string[] SaveMappedForOutputResolutions { get; set; }
@ -201,6 +202,7 @@ public class Configuration
throw new NullReferenceException(nameof(configuration.RangeDistanceTolerance));
if (configuration.Reverse is null)
throw new NullReferenceException(nameof(configuration.Reverse));
configuration.SaveBlurHashForOutputResolutions ??= Array.Empty<string>();
configuration.SaveFaceDistancesForOutputResolutions ??= Array.Empty<string>();
configuration.SaveFaceLandmarkForOutputResolutions ??= Array.Empty<string>();
if (configuration.SaveFullYearOfRandomFiles is null)
@ -288,6 +290,7 @@ public class Configuration
configuration.RangeFaceAreaTolerance,
configuration.RangeFaceConfidence,
configuration.Reverse.Value,
configuration.SaveBlurHashForOutputResolutions,
configuration.SaveFaceDistancesForOutputResolutions,
configuration.SaveFaceLandmarkForOutputResolutions,
configuration.SaveFilteredOriginalImagesFromJLinksForOutputResolutions,

View File

@ -64,6 +64,7 @@ public class Configuration
public float[] RangeFaceAreaTolerance { init; get; }
public float[] RangeFaceConfidence { init; get; }
public bool Reverse { init; get; }
public string[] SaveBlurHashForOutputResolutions { init; get; }
public string[] SaveFaceDistancesForOutputResolutions { init; get; }
public string[] SaveFaceLandmarkForOutputResolutions { init; get; }
public string[] SaveFilteredOriginalImagesFromJLinksForOutputResolutions { init; get; }
@ -141,6 +142,7 @@ public class Configuration
float[] rangeFaceAreaPermyriadTolerance,
float[] rangeFaceConfidence,
bool reverse,
string[] saveBlurHashForOutputResolutions,
string[] saveFaceDistancesForOutputResolutions,
string[] saveFaceLandmarkForOutputResolutions,
string[] saveFilteredOriginalImagesFromJLinksForOutputResolutions,
@ -217,6 +219,7 @@ public class Configuration
RangeFaceAreaTolerance = rangeFaceAreaPermyriadTolerance;
RangeFaceConfidence = rangeFaceConfidence;
Reverse = reverse;
SaveBlurHashForOutputResolutions = saveBlurHashForOutputResolutions;
SaveFaceDistancesForOutputResolutions = saveFaceDistancesForOutputResolutions;
SaveFaceLandmarkForOutputResolutions = saveFaceLandmarkForOutputResolutions;
SaveFilteredOriginalImagesFromJLinksForOutputResolutions = saveFilteredOriginalImagesFromJLinksForOutputResolutions;

View File

@ -4,114 +4,7 @@
"Log4netProvider": "Debug"
}
},
"MaxDegreeOfParallelism": 6,
"Serilog": {
"MinimumLevel": "Debug"
},
"Windows": {
"Configuration": {
"DateGroup": "1e85c0ba",
"DeletePossibleDuplicates": true,
"DistanceRenameToMatch": true,
"DistanceMoveUnableToMatch": true,
"xFaceDistanceHiddenImageFactor": 2,
"FaceDistanceHiddenImageFactor": 3,
"FocusDirectory": "",
"xFocusDirectory": "/Hawaii 2022",
"FocusModel": "",
"xFocusModel": "NIKON D3400",
"LookForAbandoned": false,
"xGenealogicalDataCommunicationFile": "",
"GenealogicalDataCommunicationFile": "D:/5) Other Small/RootsMagic/Code-638160743318283885/638160743318283885-Export.ged.cln",
"PersonCharactersCopyCount": 0,
"xPersonCharactersCopyCount": 5,
"xRootDirectory": "D:/Tmp/phares/Pictures",
"xxRootDirectory": "D:/Tmp/Phares/Compare/Corrupt",
"xxxRootDirectory": "D:/2) Images B/Not-Copy-Copy-1e85c0ba",
"RootDirectory": "D:/1) Images A/Images-1e85c0ba",
"xxxxxRootDirectory": "D:/1) Images A/Images-1e85c0ba/Facebook/2023.2 Facebook",
"SaveIndividually": false,
"xSaveIndividually": true,
"SaveSortingWithoutPerson": true,
"SkipOlderThanDays": null,
"xSkipOlderThanDays": 2200,
"CopyFacesAndSaveFaceLandmarkForOutputResolutions": [],
"xJLinks": [
"Julie"
],
"JLinks": [
"Mike Phares Jr"
],
"LoadOrCreateThenSaveDistanceResultsForOutputResolutions": [
"Original"
],
"LoadOrCreateThenSaveImageFacesResultsForOutputResolutions": [
"Original"
],
"OutputResolutions": [
"Original"
],
"PropertyContentCollectionFiles": [],
"RangeDaysDeltaTolerance": [
0,
7000,
7300
],
"RangeDistanceTolerance": [
0,
0.6,
1.8
],
"RangeFaceAreaTolerance": [
0,
0.0001,
1
],
"RangeFaceConfidence": [
0,
0.8,
2.4
],
"SaveFaceDistancesForOutputResolutions": [
"Original"
],
"SaveFaceLandmarkForOutputResolutions": [],
"SaveFilteredOriginalImagesFromJLinksForOutputResolutions": [],
"SaveMappedForOutputResolutions": [],
"SaveRandomForOutputResolutions": [],
"SaveShortcutsForOutputResolutions": [],
"SkipNotSkipDirectories": [],
"xSkipNotSkipDirectories": [
"/!/_ Images-To-Do",
"/!/_ Test",
"/!/Disney",
"/!/Chelsea's Friends",
"/!/Jason's Friends",
"/!/Johnny's Friends",
"/!/Julie's Friends",
"/!/Kristy's Family",
"/!/Kristy's Friends",
"/!/Logan Friends",
"/!/Mackenzie Friends",
"/!/Mike's Family",
"/!/Mike's Friends",
"/!/Statue",
"/!/Tracy's Friend",
"/!/Wax"
],
"IgnoreRelativePaths": [
"zzz Phares Slides ####"
],
"MixedYearRelativePaths": [
"Edited",
"Phares Slides",
"Rex Memorial",
"Scanned Grandma's Quilt",
"Scanned Pictures Of Kids",
"Scanned Prints",
"Slide in Name Order Originals (622)",
"Slides Pictures"
]
}
}
}