diff --git a/Code/ExtensionMethods.cs b/Code/ExtensionMethods.cs index 36ed15c..29b5b11 100644 --- a/Code/ExtensionMethods.cs +++ b/Code/ExtensionMethods.cs @@ -97,10 +97,10 @@ namespace Flowframes return Regex.Split(str, "\r\n|\r|\n"); } - public static string Trunc(this string value, int maxChars, bool addEllipsis = true) + public static string Trunc(this string inStr, int maxChars, bool addEllipsis = true) { - string str = value.Length <= maxChars ? value : value.Substring(0, maxChars); - if(addEllipsis) + string str = inStr.Length <= maxChars ? inStr : inStr.Substring(0, maxChars); + if(addEllipsis && inStr.Length > maxChars) str += "…"; return str; } diff --git a/Code/Main/Interpolate.cs b/Code/Main/Interpolate.cs index a4075f4..de24bbb 100644 --- a/Code/Main/Interpolate.cs +++ b/Code/Main/Interpolate.cs @@ -144,6 +144,7 @@ namespace Flowframes public static async Task PostProcessFrames (bool sbsMode = false) { bool firstFrameFix = (!sbsMode && lastAi.aiName == Networks.rifeCuda.aiName) || (sbsMode && InterpolateSteps.currentAi.aiName == Networks.rifeCuda.aiName); + //firstFrameFix = false; // TODO: Remove firstframefix if new rife code works if (!Directory.Exists(currentFramesPath) || IOUtils.GetAmountOfFiles(currentFramesPath, false, "*.png") <= 0) { @@ -182,8 +183,10 @@ namespace Flowframes public static async Task RunAi(string outpath, int targetFrames, int tilesize, AI ai) { - currentlyUsingAutoEnc = IOUtils.GetAmountOfFiles(currentFramesPath, false) >= (AutoEncode.chunkSize + AutoEncode.safetyBufferFrames) * 1.2f; - + currentlyUsingAutoEnc = IOUtils.GetAmountOfFiles(currentFramesPath, false) * lastInterpFactor >= (AutoEncode.chunkSize + AutoEncode.safetyBufferFrames) * 1.2f; + //Logger.Log("Using autoenc if there's more than " + (AutoEncode.chunkSize + AutoEncode.safetyBufferFrames) * 1.2f + " input frames, got " + IOUtils.GetAmountOfFiles(currentFramesPath, false) * lastInterpFactor); + currentlyUsingAutoEnc = false; + Directory.CreateDirectory(outpath); List tasks = new List(); @@ -200,8 +203,8 @@ namespace Flowframes if (ai.aiName == Networks.rifeNcnn.aiName) tasks.Add(AiProcess.RunRifeNcnnMulti(currentFramesPath, outpath, tilesize, interpFactor)); - //if(currentlyUsingAutoEnc) - // tasks.Add(AutoEncode.MainLoop(outpath)); + if(currentlyUsingAutoEnc) + tasks.Add(AutoEncode.MainLoop(outpath)); await Task.WhenAll(tasks); } diff --git a/Code/OS/AiProcess.cs b/Code/OS/AiProcess.cs index 0011c06..ca25e78 100644 --- a/Code/OS/AiProcess.cs +++ b/Code/OS/AiProcess.cs @@ -139,13 +139,21 @@ namespace Flowframes public static async Task RunRifeCuda(string framesPath, int interpFactor) { string script = "interp-parallel.py"; - if(Config.GetInt("rifeMode") == 0 || IOUtils.GetAmountOfFiles(framesPath, false) < 6) - script = "interp-basic.py"; + //if(Config.GetInt("rifeMode") == 0 || IOUtils.GetAmountOfFiles(framesPath, false) < 6) + // script = "interp-basic.py"; string rifeDir = Path.Combine(Paths.GetPkgPath(), Path.GetFileNameWithoutExtension(Packages.rifeCuda.fileName)); + + string args = $" --input {framesPath.Wrap()} --times {(int)Math.Log(interpFactor, 2)}"; + + if (File.Exists(Path.Combine(rifeDir, "inference_video.py"))) // Use updated script + { + script = "inference_video.py"; + args = $" --img {framesPath.Wrap()} --exp {(int)Math.Log(interpFactor, 2)}"; + } + Process rifePy = OSUtils.NewProcess(!OSUtils.ShowHiddenCmd()); AiStarted(rifePy, 3000, "png"); - string args = $" --input {framesPath.Wrap()} --times {(int)Math.Log(interpFactor, 2)}"; rifePy.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {PkgUtils.GetPkgFolder(Packages.rifeCuda).Wrap()} & " + $"set CUDA_VISIBLE_DEVICES={Config.Get("torchGpus")} & {Pytorch.GetPyCmd()} {script} {args} --imgformat {InterpolateUtils.lastExt} --output {Paths.interpDir}"; Logger.Log($"Running RIFE ({script})...", false);