From 2ac003a1b15d0d368bb76d8d3f36ef7ba84c6757 Mon Sep 17 00:00:00 2001 From: n00mkrad Date: Sun, 17 Apr 2022 18:39:32 +0200 Subject: [PATCH] Lock pre-4.0 rife ncnn models to 2x --- Code/IO/ModelDownloader.cs | 2 +- Code/Os/AiProcess.cs | 3 ++- Code/Ui/MainUiFunctions.cs | 10 +++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Code/IO/ModelDownloader.cs b/Code/IO/ModelDownloader.cs index 7ea1242..723014f 100644 --- a/Code/IO/ModelDownloader.cs +++ b/Code/IO/ModelDownloader.cs @@ -135,7 +135,7 @@ namespace Flowframes.IO public static async Task DownloadModelFiles (AI ai, string modelDir, bool log = true) { string aiDir = ai.pkgDir; - Logger.Log($"DownloadModelFiles(string ai = {ai}, string model = {modelDir}, bool log = {log})", true); + Logger.Log($"DownloadModelFiles(string ai = {ai.aiName}, string model = {modelDir}, bool log = {log})", true); try { diff --git a/Code/Os/AiProcess.cs b/Code/Os/AiProcess.cs index dae6e9e..284122e 100644 --- a/Code/Os/AiProcess.cs +++ b/Code/Os/AiProcess.cs @@ -272,11 +272,12 @@ namespace Flowframes.Os SetProgressCheck(outPath, factor); int targetFrames = ((IoUtils.GetAmountOfFiles(lastInPath, false, "*.*") * factor).RoundToInt()); // TODO: Maybe won't work with fractional factors ?? + string frames = mdl.Contains("v4") ? $"-n {targetFrames}" : ""; string uhdStr = await InterpolateUtils.UseUhd() ? "-u" : ""; string ttaStr = Config.GetBool(Config.Key.rifeNcnnUseTta, false) ? "-x" : ""; rifeNcnn.StartInfo.Arguments = $"{OsUtils.GetCmdArg()} cd /D {Path.Combine(Paths.GetPkgPath(), Implementations.rifeNcnn.pkgDir).Wrap()} & rife-ncnn-vulkan.exe " + - $" -v -i {inPath.Wrap()} -o {outPath.Wrap()} -n {targetFrames} -m {mdl.ToLower()} {ttaStr} {uhdStr} -g {Config.Get(Config.Key.ncnnGpus)} -f {GetNcnnPattern()} -j {GetNcnnThreads()}"; + $" -v -i {inPath.Wrap()} -o {outPath.Wrap()} {frames} -m {mdl.ToLower()} {ttaStr} {uhdStr} -g {Config.Get(Config.Key.ncnnGpus)} -f {GetNcnnPattern()} -j {GetNcnnThreads()}"; Logger.Log("cmd.exe " + rifeNcnn.StartInfo.Arguments, true); diff --git a/Code/Ui/MainUiFunctions.cs b/Code/Ui/MainUiFunctions.cs index 87bdb61..7f9ac0f 100644 --- a/Code/Ui/MainUiFunctions.cs +++ b/Code/Ui/MainUiFunctions.cs @@ -157,7 +157,15 @@ namespace Flowframes.Ui { AI ai = Program.mainForm.GetAi(); - if(ai.factorSupport == AI.FactorSupport.Fixed) + if (ai.aiName == Implementations.rifeNcnn.aiName && !Program.mainForm.GetModel(ai).dir.Contains("v4")) + { + if (factor != 2) + Logger.Log($"{ai.friendlyName} models before 4.0 only support 2x interpolation!"); + + return 2; + } + + if (ai.factorSupport == AI.FactorSupport.Fixed) { int closest = ai.supportedFactors.Min(i => (Math.Abs(factor.RoundToInt() - i), i)).i; return (float)closest;