mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-16 16:37:48 +01:00
ifrnet-ncnn-vulkan implementation test
This commit is contained in:
@@ -21,7 +21,7 @@ namespace Flowframes.Data
|
||||
public int[] SupportedFactors { get; set; } = new int[0];
|
||||
public bool Piped { get; set; } = false;
|
||||
|
||||
public string LogFilename { get { return AiName.Replace("_", "-").ToLower() + "-log"; } }
|
||||
public string LogFilename { get { return PkgDir + "-log"; } }
|
||||
|
||||
public AI(AiBackend backend, string aiName, string friendlyName, string desc, string pkgDir, InterpFactorSupport factorSupport = InterpFactorSupport.Fixed, int[] supportedFactors = null)
|
||||
{
|
||||
|
||||
@@ -25,11 +25,14 @@ namespace Flowframes.Data
|
||||
public static AI xvfiCuda = new AI(AI.AiBackend.Pytorch, "XVFI_CUDA", "XVFI",
|
||||
"CUDA/Pytorch Implementation of XVFI", "xvfi-cuda", AI.InterpFactorSupport.AnyInteger, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 });
|
||||
|
||||
public static AI ifrnetNcnn = new AI(AI.AiBackend.Ncnn, "IFRNet_NCNN", "IFRNet (NCNN)",
|
||||
"Vulkan/NCNN Implementation of IFRNet", "ifrnet-ncnn", AI.InterpFactorSupport.Fixed, new int[] { 2 });
|
||||
|
||||
public static List<AI> NetworksAll
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<AI> { rifeCuda, rifeNcnnVs, rifeNcnn, flavrCuda, dainNcnn, xvfiCuda };
|
||||
return new List<AI> { rifeCuda, rifeNcnnVs, rifeNcnn, flavrCuda, dainNcnn, xvfiCuda, /* ifrnetNcnn */ };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -214,6 +214,9 @@ namespace Flowframes
|
||||
if (ai.AiName == Implementations.xvfiCuda.AiName)
|
||||
tasks.Add(AiProcess.RunXvfiCuda(currentSettings.framesFolder, currentSettings.interpFactor, currentSettings.model.dir));
|
||||
|
||||
if(ai.AiName == Implementations.ifrnetNcnn.AiName)
|
||||
tasks.Add(AiProcess.RunIfrnetNcnn(currentSettings.framesFolder, outpath, currentSettings.interpFactor, currentSettings.model.dir));
|
||||
|
||||
if (currentlyUsingAutoEnc)
|
||||
{
|
||||
Logger.Log($"{Logger.GetLastLine()} (Using Auto-Encode)", true);
|
||||
|
||||
@@ -531,6 +531,59 @@ namespace Flowframes.Os
|
||||
while (!xvfiPy.HasExited) await Task.Delay(1);
|
||||
}
|
||||
|
||||
public static async Task RunIfrnetNcnn(string framesPath, string outPath, float factor, string mdl)
|
||||
{
|
||||
processTimeMulti.Restart();
|
||||
|
||||
try
|
||||
{
|
||||
Logger.Log($"Running IFRNet (NCNN){(await InterpolateUtils.UseUhd() ? " (UHD Mode)" : "")}...", false);
|
||||
|
||||
await RunIfrnetNcnnProcess(framesPath, factor, outPath, mdl);
|
||||
await DeleteNcnnDupes(outPath, factor);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log("Error running IFRNet-NCNN: " + e.Message);
|
||||
Logger.Log("Stack Trace: " + e.StackTrace, true);
|
||||
}
|
||||
|
||||
await AiFinished("IFRNet");
|
||||
}
|
||||
|
||||
static async Task RunIfrnetNcnnProcess(string inPath, float factor, string outPath, string mdl)
|
||||
{
|
||||
Directory.CreateDirectory(outPath);
|
||||
Process ifrnetNcnn = OsUtils.NewProcess(!OsUtils.ShowHiddenCmd());
|
||||
AiStarted(ifrnetNcnn, 1500, inPath);
|
||||
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" : "";
|
||||
|
||||
ifrnetNcnn.StartInfo.Arguments = $"{OsUtils.GetCmdArg()} cd /D {Path.Combine(Paths.GetPkgPath(), Implementations.ifrnetNcnn.PkgDir).Wrap()} & ifrnet-ncnn-vulkan.exe " +
|
||||
$" -v -i {inPath.Wrap()} -o {outPath.Wrap()} -m {mdl} {ttaStr} {uhdStr} -g {Config.Get(Config.Key.ncnnGpus)} -f {GetNcnnPattern()} -j {GetNcnnThreads()}";
|
||||
|
||||
Logger.Log("cmd.exe " + ifrnetNcnn.StartInfo.Arguments, true);
|
||||
|
||||
if (!OsUtils.ShowHiddenCmd())
|
||||
{
|
||||
ifrnetNcnn.OutputDataReceived += (sender, outLine) => { LogOutput("[O] " + outLine.Data, Implementations.ifrnetNcnn); };
|
||||
ifrnetNcnn.ErrorDataReceived += (sender, outLine) => { LogOutput("[E] " + outLine.Data, Implementations.ifrnetNcnn, true); };
|
||||
}
|
||||
|
||||
ifrnetNcnn.Start();
|
||||
|
||||
if (!OsUtils.ShowHiddenCmd())
|
||||
{
|
||||
ifrnetNcnn.BeginOutputReadLine();
|
||||
ifrnetNcnn.BeginErrorReadLine();
|
||||
}
|
||||
|
||||
while (!ifrnetNcnn.HasExited) await Task.Delay(1);
|
||||
}
|
||||
|
||||
static void LogOutput(string line, AI ai, bool err = false)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(line) || line.Length < 6)
|
||||
|
||||
Reference in New Issue
Block a user