From 70fe5291e9e8a5e2918b075cb3dc8cbcf248599c Mon Sep 17 00:00:00 2001 From: Richard Date: Thu, 11 Feb 2021 21:05:45 +0100 Subject: [PATCH] fix progress --- Code/Main/InterpolateUtils.cs | 4 ++-- Code/OS/AiProcess.cs | 17 +++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Code/Main/InterpolateUtils.cs b/Code/Main/InterpolateUtils.cs index d8d936a..f0704bd 100644 --- a/Code/Main/InterpolateUtils.cs +++ b/Code/Main/InterpolateUtils.cs @@ -97,8 +97,8 @@ namespace Flowframes.Main public static void UpdateLastFrameFromInterpOutput(string output) { - string dainStr = AiProcess.currentAiName == "DAIN" ? " done" : ""; - Regex frameRegex = new Regex($@"(?<=.)\d*(?=.{GetOutExt()}{dainStr})"); + string ncnnStr = Interpolate.current.ai.aiName.Contains("NCNN") ? " done" : ""; + Regex frameRegex = new Regex($@"(?<=.)\d*(?=.{GetOutExt()}{ncnnStr})"); if (!frameRegex.IsMatch(output)) return; lastFrame = Math.Max(int.Parse(frameRegex.Match(output).Value), lastFrame); } diff --git a/Code/OS/AiProcess.cs b/Code/OS/AiProcess.cs index 36d0b3e..8937f86 100644 --- a/Code/OS/AiProcess.cs +++ b/Code/OS/AiProcess.cs @@ -22,7 +22,6 @@ namespace Flowframes public static bool hasShownError; public static Process currentAiProcess; - public static string currentAiName; public static Stopwatch processTime = new Stopwatch(); public static Stopwatch processTimeMulti = new Stopwatch(); @@ -53,12 +52,12 @@ namespace Flowframes InterpolateUtils.GetProgressByFrameAmount(interpPath, target); } - static async Task AiFinished() + static async Task AiFinished(string aiName) { if (Interpolate.canceled) return; Program.mainForm.SetProgress(100); InterpolateUtils.UpdateInterpProgress(IOUtils.GetAmountOfFiles(Interpolate.current.interpFolder, false, "*.png"), InterpolateUtils.targetFrames); - string logStr = $"Done running {currentAiName} - Interpolation took {FormatUtils.Time(processTime.Elapsed)}"; + string logStr = $"Done running {aiName} - Interpolation took {FormatUtils.Time(processTime.Elapsed)}"; if (Interpolate.currentlyUsingAutoEnc && AutoEncode.HasWorkToDo()) logStr += " - Waiting for encoding to finish..."; Logger.Log(logStr); @@ -93,8 +92,6 @@ namespace Flowframes if(Interpolate.currentlyUsingAutoEnc) // Ensure AutoEnc is not paused AutoEncode.paused = false; - currentAiName = "RIFE"; - string rifeDir = Path.Combine(Paths.GetPkgPath(), Path.GetFileNameWithoutExtension(Packages.rifeCuda.fileName)); string script = "rife.py"; @@ -113,7 +110,7 @@ namespace Flowframes await RunRifeCudaProcess(framesPath + Paths.alphaSuffix, Paths.interpDir + Paths.alphaSuffix, script, interpFactor, mdl); } - await AiFinished(); + await AiFinished("RIFE"); } public static async Task RunRifeCudaProcess (string inPath, string outDir, string script, float interpFactor, string mdl) @@ -154,8 +151,6 @@ namespace Flowframes processTimeMulti.Restart(); Logger.Log($"Running RIFE{(await InterpolateUtils.UseUHD() ? " (UHD Mode)" : "")}...", false); - currentAiName = "RIFE"; - await RunRifeNcnnMulti(framesPath, outPath, factor, mdl); if (!Interpolate.canceled && Interpolate.current.alpha) @@ -164,6 +159,8 @@ namespace Flowframes Logger.Log("Interpolating alpha channel..."); await RunRifeNcnnMulti(framesPath + Paths.alphaSuffix, outPath + Paths.alphaSuffix, factor, mdl); } + + await AiFinished("RIFE"); } static async Task RunRifeNcnnMulti(string framesPath, string outPath, int factor, string mdl) @@ -238,8 +235,6 @@ namespace Flowframes if (Interpolate.currentlyUsingAutoEnc) // Ensure AutoEnc is not paused AutoEncode.paused = false; - currentAiName = "DAIN"; - await RunDainNcnnProcess(framesPath, outPath, factor, mdl, tilesize); if (!Interpolate.canceled && Interpolate.current.alpha) @@ -248,6 +243,8 @@ namespace Flowframes Logger.Log("Interpolating alpha channel..."); await RunDainNcnnProcess(framesPath + Paths.alphaSuffix, outPath + Paths.alphaSuffix, factor, mdl, tilesize); } + + await AiFinished("DAIN"); } public static async Task RunDainNcnnProcess (string framesPath, string outPath, float factor, string mdl, int tilesize)