From 943c87845fbe2ab84e751fb1e8fd1e53b89fdbb6 Mon Sep 17 00:00:00 2001 From: N00MKRAD Date: Sun, 4 Apr 2021 12:46:41 +0200 Subject: [PATCH] Cleanup, fixed dupe dict not working with new code --- Code/Magick/Blend.cs | 14 -------------- Code/Main/FrameOrder.cs | 15 ++++++++------- Code/MiscUtils/FrameRename.cs | 9 --------- Code/OS/AiProcess.cs | 5 ----- 4 files changed, 8 insertions(+), 35 deletions(-) diff --git a/Code/Magick/Blend.cs b/Code/Magick/Blend.cs index da92449..98259b1 100644 --- a/Code/Magick/Blend.cs +++ b/Code/Magick/Blend.cs @@ -36,14 +36,6 @@ namespace Flowframes.Magick if (setStatus) Program.mainForm.SetStatus("Blending scene transitions..."); - // bool renameFramesFirst = !FrameRename.framesAreRenamed; - // - // if (renameFramesFirst) - // { - // Dictionary renamedFilesDict = await IOUtils.RenameCounterDirReversibleAsync(Interpolate.current.framesFolder, "png", 1, Padding.inputFramesRenamed); - // AiProcess.SetFilenameMap(renamedFilesDict.ToDictionary(x => Path.GetFileName(x.Key), x => Path.GetFileName(x.Value)), true); - // } - int amountOfBlendFrames = (int)Interpolate.current.interpFactor - 1; List runningTasks = new List(); @@ -109,12 +101,6 @@ namespace Flowframes.Magick Logger.Log($"Created {totalFrames} blend frames in {FormatUtils.TimeSw(sw)} ({(totalFrames / (sw.ElapsedMilliseconds / 1000f)).ToString("0.00")} FPS)", true); - // if (renameFramesFirst) - // { - // await IOUtils.ReverseRenaming(Interpolate.current.framesFolder, FrameRename.filenameMap); // Get timestamps back - // AiProcess.SetFilenameMap(null, false); - // } - if (setStatus) Program.mainForm.SetStatus(oldStatus); } diff --git a/Code/Main/FrameOrder.cs b/Code/Main/FrameOrder.cs index 03d85af..981ab2e 100644 --- a/Code/Main/FrameOrder.cs +++ b/Code/Main/FrameOrder.cs @@ -123,9 +123,10 @@ namespace Flowframes.Main if (Interpolate.canceled) return; if (i >= frameFilesWithoutLast.Length) break; - string inputFilenameNoExt = Path.GetFileNameWithoutExtension(frameFilesWithoutLast[i].Name); - int dupesAmount = dupesDict.ContainsKey(inputFilenameNoExt) ? dupesDict[inputFilenameNoExt] : 0; - bool discardThisFrame = (sceneDetection && i < frameFilesWithoutLast.Length && sceneFrames.Contains(Path.GetFileNameWithoutExtension(FrameRename.importFilenames[i + 1]))); // i+2 is in scene detection folder, means i+1 is ugly interp frame + string frameName = Path.GetFileNameWithoutExtension(frameFilesWithoutLast[i].Name); + string frameNameImport = Path.GetFileNameWithoutExtension(FrameRename.importFilenames[i]); + int dupesAmount = dupesDict.ContainsKey(frameNameImport) ? dupesDict[frameNameImport] : 0; + bool discardThisFrame = (sceneDetection && i < frameFilesWithoutLast.Length && sceneFrames.Contains(frameNameImport)); // i+2 is in scene detection folder, means i+1 is ugly interp frame for (int frm = 0; frm < interpFramesAmount; frm++) // Generate frames file lines { @@ -136,7 +137,7 @@ namespace Flowframes.Main string scnChangeNote = $"SCN:{frameBeforeScn}>{frameAfterScn}"; totalFileCount++; - fileContent = WriteFrameWithDupes(dupesAmount, fileContent, totalFileCount, ext, debug, $"[In: {inputFilenameNoExt}] [{((frm == 0) ? " Source " : $"Interp {frm}")}]", scnChangeNote); + fileContent = WriteFrameWithDupes(dupesAmount, fileContent, totalFileCount, ext, debug, $"[In: {frameName}] [{((frm == 0) ? " Source " : $"Interp {frm}")}]", scnChangeNote); if (Config.GetInt("sceneChangeFillMode") == 0) // Duplicate last frame { @@ -145,7 +146,7 @@ namespace Flowframes.Main for (int dupeCount = 1; dupeCount < interpFramesAmount; dupeCount++) { totalFileCount++; - fileContent = WriteFrameWithDupes(dupesAmount, fileContent, lastNum, ext, debug, $"[In: {inputFilenameNoExt}] [DISCARDED]"); + fileContent = WriteFrameWithDupes(dupesAmount, fileContent, lastNum, ext, debug, $"[In: {frameName}] [DISCARDED]"); } } else @@ -153,7 +154,7 @@ namespace Flowframes.Main for (int dupeCount = 1; dupeCount < interpFramesAmount; dupeCount++) { totalFileCount++; - fileContent = WriteFrameWithDupes(dupesAmount, fileContent, totalFileCount, ext, debug, $"[In: {inputFilenameNoExt}] [BLEND FRAME]"); + fileContent = WriteFrameWithDupes(dupesAmount, fileContent, totalFileCount, ext, debug, $"[In: {frameName}] [BLEND FRAME]"); } } @@ -162,7 +163,7 @@ namespace Flowframes.Main else { totalFileCount++; - fileContent = WriteFrameWithDupes(dupesAmount, fileContent, totalFileCount, ext, debug, $"[In: {inputFilenameNoExt}] [{((frm == 0) ? " Source " : $"Interp {frm}")}]"); + fileContent = WriteFrameWithDupes(dupesAmount, fileContent, totalFileCount, ext, debug, $"[In: {frameName}] [{((frm == 0) ? " Source " : $"Interp {frm}")}]"); } } } diff --git a/Code/MiscUtils/FrameRename.cs b/Code/MiscUtils/FrameRename.cs index a19d07d..fdb0f09 100644 --- a/Code/MiscUtils/FrameRename.cs +++ b/Code/MiscUtils/FrameRename.cs @@ -14,20 +14,11 @@ namespace Flowframes.MiscUtils { public static bool framesAreRenamed; public static string[] importFilenames; // index=renamed, value=original TODO: Store on disk instead for crashes? - public static Dictionary originalFilenamesReversed; public static async Task Rename() { importFilenames = IOUtils.GetFilesSorted(Interpolate.current.framesFolder).Select(x => Path.GetFileName(x)).ToArray(); - //originalFilenamesReversed = new string[originalFilenames.Length]; await IOUtils.RenameCounterDir(Interpolate.current.framesFolder, 0, Padding.inputFramesRenamed); - - //for(int i = 0; i < originalFilenames.Length; i++) - //{ - // int idx = originalFilenames[i].GetInt(); - // originalFilenamesReversed[idx] = originalFilenames[i]; - //} - framesAreRenamed = true; } diff --git a/Code/OS/AiProcess.cs b/Code/OS/AiProcess.cs index a988997..c3e52ef 100644 --- a/Code/OS/AiProcess.cs +++ b/Code/OS/AiProcess.cs @@ -211,11 +211,6 @@ namespace Flowframes { string outPath = Path.Combine(inPath.GetParentDir(), outDir); Directory.CreateDirectory(outPath); - //string uhdStr = await InterpolateUtils.UseUHD() ? "--UHD" : ""; - //string wthreads = $"--wthreads {2 * (int)interpFactor}"; - //string rbuffer = $"--rbuffer {Config.GetInt("flavrCudaBufferSize", 200)}"; - //string scale = $"--scale {Config.GetFloat("flavrCudaScale", 1.0f).ToStringDot()}"; - // string prec = Config.GetBool("flavrCudaFp16") ? "--fp16" : ""; string args = $" --input {inPath.Wrap()} --output {outPath.Wrap()} --model {mdl}/{mdl}.pth --factor {interpFactor}"; Process flavrPy = OSUtils.NewProcess(!OSUtils.ShowHiddenCmd());