fix progress

This commit is contained in:
Richard 2021-02-11 21:05:45 +01:00
parent 5e6ef03345
commit 70fe5291e9
2 changed files with 9 additions and 12 deletions

View File

@ -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);
}

View File

@ -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)