mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-16 08:27:44 +01:00
Fixed autoenc problem, RunRifeCuda now works with old and new scripts
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<Task> tasks = new List<Task>();
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user