From deb99070e44acac6f64b2f95fa9061bf3246d12b Mon Sep 17 00:00:00 2001 From: N00MKRAD Date: Sun, 28 Feb 2021 16:34:47 +0100 Subject: [PATCH] RIFE CUDA scale arg from config --- Code/IO/Config.cs | 6 ++++++ Code/OS/AiProcess.cs | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Code/IO/Config.cs b/Code/IO/Config.cs index 4237d03..696a763 100644 --- a/Code/IO/Config.cs +++ b/Code/IO/Config.cs @@ -113,6 +113,12 @@ namespace Flowframes.IO return float.Parse(Get(key, Type.Float), CultureInfo.InvariantCulture); } + public static float GetFloat(string key, float defaultVal) + { + WriteIfDoesntExist(key, defaultVal.ToStringDot()); + return float.Parse(Get(key, Type.Float), CultureInfo.InvariantCulture); + } + public static string GetFloatString (string key) { return Get(key, Type.Float).Replace(",", "."); diff --git a/Code/OS/AiProcess.cs b/Code/OS/AiProcess.cs index 4a8bb23..76e2278 100644 --- a/Code/OS/AiProcess.cs +++ b/Code/OS/AiProcess.cs @@ -117,12 +117,12 @@ namespace Flowframes public static async Task RunRifeCudaProcess (string inPath, string outDir, string script, float interpFactor, string mdl) { //bool parallel = false; - string uhdStr = await InterpolateUtils.UseUHD() ? "--UHD" : ""; string outPath = Path.Combine(inPath.GetParentDir(), outDir); string wthreads = $"--wthreads {2 * (int)interpFactor}"; string rbuffer = $"--rbuffer {Config.GetInt("rifeCudaBufferSize", 200)}"; + string scale = $"--scale {Config.GetFloat("rifeCudaScale", 1.0f).ToStringDot()}"; string prec = Config.GetBool("rifeCudaFp16") ? "--fp16" : ""; - string args = $" --input {inPath.Wrap()} --output {outDir} --model {mdl} --exp {(int)Math.Log(interpFactor, 2)} {wthreads} {rbuffer} {prec}"; + string args = $" --input {inPath.Wrap()} --output {outDir} --model {mdl} --exp {(int)Math.Log(interpFactor, 2)} {scale} {wthreads} {rbuffer} {prec}"; // if (parallel) args = $" --input {inPath.Wrap()} --output {outPath} --model {mdl} --factor {interpFactor}"; // if (parallel) script = "rife-parallel.py"; @@ -131,7 +131,7 @@ namespace Flowframes SetProgressCheck(Path.Combine(Interpolate.current.tempFolder, outDir), interpFactor); rifePy.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {PkgUtils.GetPkgFolder(Packages.rifeCuda).Wrap()} & " + $"set CUDA_VISIBLE_DEVICES={Config.Get("torchGpus")} & {Python.GetPyCmd()} {script} {args}"; - Logger.Log($"Running RIFE {(await InterpolateUtils.UseUHD() ? "(UHD Mode)" : "")} ({script})...".TrimWhitespaces(), false); + Logger.Log($"Running RIFE (CUDA)...".TrimWhitespaces(), false); Logger.Log("cmd.exe " + rifePy.StartInfo.Arguments, true); if (!OSUtils.ShowHiddenCmd()) @@ -152,7 +152,7 @@ namespace Flowframes public static async Task RunRifeNcnn (string framesPath, string outPath, int factor, string mdl) { processTimeMulti.Restart(); - Logger.Log($"Running RIFE{(await InterpolateUtils.UseUHD() ? " (UHD Mode)" : "")}...", false); + Logger.Log($"Running RIFE (NCNN){(await InterpolateUtils.UseUHD() ? " (UHD Mode)" : "")}...", false); await RunRifeNcnnMulti(framesPath, outPath, factor, mdl);