mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-25 04:39:25 +01:00
XVFI test
This commit is contained in:
@@ -10,6 +10,7 @@ namespace Flowframes.Data
|
||||
public static AI rifeNcnn = new AI("RIFE_NCNN", "RIFE (NCNN)", "Vulkan/NCNN Implementation of RIFE", "rife-ncnn", false);
|
||||
public static AI flavrCuda = new AI("FLAVR_CUDA", "FLAVR", "Experimental Pytorch Implementation of FLAVR (Nvidia Only!)", "flavr-cuda", true);
|
||||
public static AI dainNcnn = new AI("DAIN_NCNN", "DAIN (NCNN)", "Vulkan/NCNN Implementation of DAIN", "dain-ncnn", true);
|
||||
public static AI xvfiCuda = new AI("XVFI_CUDA", "XVFI", "CUDA / Pytorch Implementation of XVFI (Nvidia Only!)", "xvfi-cuda", true);
|
||||
|
||||
public static List<AI> networks = new List<AI>();
|
||||
|
||||
@@ -20,6 +21,7 @@ namespace Flowframes.Data
|
||||
networks.Add(rifeNcnn);
|
||||
networks.Add(flavrCuda);
|
||||
networks.Add(dainNcnn);
|
||||
networks.Add(xvfiCuda);
|
||||
}
|
||||
|
||||
public static AI GetAi (string aiName)
|
||||
|
||||
@@ -339,7 +339,7 @@
|
||||
<Compile Include="Data\VidExtraData.cs" />
|
||||
<Compile Include="Data\Fraction.cs" />
|
||||
<Compile Include="Data\InterpSettings.cs" />
|
||||
<Compile Include="Data\Networks.cs" />
|
||||
<Compile Include="Data\Implementations.cs" />
|
||||
<Compile Include="Data\Padding.cs" />
|
||||
<Compile Include="Data\PseudoUniqueFile.cs" />
|
||||
<Compile Include="Data\ResumeState.cs" />
|
||||
|
||||
@@ -190,6 +190,9 @@ namespace Flowframes
|
||||
if (ai.aiName == Implementations.dainNcnn.aiName)
|
||||
tasks.Add(AiProcess.RunDainNcnn(current.framesFolder, outpath, current.interpFactor, current.model.dir, Config.GetInt(Config.Key.dainNcnnTilesize, 512)));
|
||||
|
||||
if (ai.aiName == Implementations.xvfiCuda.aiName)
|
||||
tasks.Add(AiProcess.RunXvfiCuda(current.framesFolder, current.interpFactor, current.model.dir));
|
||||
|
||||
if (currentlyUsingAutoEnc)
|
||||
{
|
||||
Logger.Log($"{Logger.GetLastLine()} (Using Auto-Encode)", true);
|
||||
|
||||
@@ -208,7 +208,7 @@ namespace Flowframes
|
||||
string args = $" --input {inPath.Wrap()} --output {outPath.Wrap()} --model {mdl}/{mdl}.pth --factor {interpFactor}";
|
||||
|
||||
Process flavrPy = OSUtils.NewProcess(!OSUtils.ShowHiddenCmd());
|
||||
AiStarted(flavrPy, 4500);
|
||||
AiStarted(flavrPy, 4000);
|
||||
SetProgressCheck(Path.Combine(Interpolate.current.tempFolder, outDir), interpFactor);
|
||||
flavrPy.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {Path.Combine(Paths.GetPkgPath(), Implementations.flavrCuda.pkgDir).Wrap()} & " +
|
||||
$"set CUDA_VISIBLE_DEVICES={Config.Get(Config.Key.torchGpus)} & {Python.GetPyCmd()} {script} {args}";
|
||||
@@ -364,6 +364,67 @@ namespace Flowframes
|
||||
await Task.Delay(100);
|
||||
}
|
||||
|
||||
public static async Task RunXvfiCuda(string framesPath, float interpFactor, string mdl)
|
||||
{
|
||||
if (Interpolate.currentlyUsingAutoEnc) // Ensure AutoEnc is not paused
|
||||
AutoEncode.paused = false;
|
||||
|
||||
try
|
||||
{
|
||||
string xvfiDir = Path.Combine(Paths.GetPkgPath(), Implementations.xvfiCuda.pkgDir);
|
||||
string script = "main.py";
|
||||
|
||||
if (!File.Exists(Path.Combine(xvfiDir, script)))
|
||||
{
|
||||
Interpolate.Cancel("XVFI script not found! Make sure you didn't modify any files.");
|
||||
return;
|
||||
}
|
||||
|
||||
await RunXvfiCudaProcess(framesPath, Paths.interpDir, script, interpFactor, mdl);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log("Error running XVFI-CUDA: " + e.Message);
|
||||
}
|
||||
|
||||
await AiFinished("XVFI");
|
||||
}
|
||||
|
||||
public static async Task RunXvfiCudaProcess(string inPath, string outDir, string script, float interpFactor, string mdlDir)
|
||||
{
|
||||
string pkgPath = Path.Combine(Paths.GetPkgPath(), Implementations.xvfiCuda.pkgDir);
|
||||
string basePath = inPath.GetParentDir();
|
||||
string outPath = Path.Combine(basePath, outDir);
|
||||
Directory.CreateDirectory(outPath);
|
||||
string mdlArgs = File.ReadAllText(Path.Combine(pkgPath, mdlDir, "args.txt"));
|
||||
string args = $" --custom_path {basePath} --input {inPath.Wrap()} --output {outPath.Wrap()} --mdl_dir {mdlDir}" +
|
||||
$" --multiple {interpFactor} --gpu 0 {mdlArgs}";
|
||||
|
||||
Process xvfiPy = OSUtils.NewProcess(!OSUtils.ShowHiddenCmd());
|
||||
AiStarted(xvfiPy, 4500);
|
||||
SetProgressCheck(Path.Combine(Interpolate.current.tempFolder, outDir), interpFactor);
|
||||
xvfiPy.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {pkgPath.Wrap()} & " +
|
||||
$"set CUDA_VISIBLE_DEVICES={Config.Get(Config.Key.torchGpus)} & {Python.GetPyCmd()} {script} {args}";
|
||||
Logger.Log($"Running XVFI (CUDA)...", false);
|
||||
Logger.Log("cmd.exe " + xvfiPy.StartInfo.Arguments, true);
|
||||
|
||||
if (!OSUtils.ShowHiddenCmd())
|
||||
{
|
||||
xvfiPy.OutputDataReceived += (sender, outLine) => { LogOutput(outLine.Data, "xvfi-cuda-log"); };
|
||||
xvfiPy.ErrorDataReceived += (sender, outLine) => { LogOutput("[E] " + outLine.Data, "xvfi-cuda-log", true); };
|
||||
}
|
||||
|
||||
xvfiPy.Start();
|
||||
|
||||
if (!OSUtils.ShowHiddenCmd())
|
||||
{
|
||||
xvfiPy.BeginOutputReadLine();
|
||||
xvfiPy.BeginErrorReadLine();
|
||||
}
|
||||
|
||||
while (!xvfiPy.HasExited) await Task.Delay(1);
|
||||
}
|
||||
|
||||
static void LogOutput (string line, string logFilename, bool err = false)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(line) || line.Length < 6)
|
||||
|
||||
Reference in New Issue
Block a user