Rename Networks => Implementations

This commit is contained in:
n00mkrad
2021-08-15 11:10:18 +02:00
parent bebd947b7a
commit b1b60ecc69
12 changed files with 30 additions and 29 deletions

View File

@@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace Flowframes.Data
{
class Networks
class Implementations
{
public static AI rifeCuda = new AI("RIFE_CUDA", "RIFE", "CUDA/Pytorch Implementation of RIFE (Nvidia Only!)", "rife-cuda", true);
public static AI rifeNcnn = new AI("RIFE_NCNN", "RIFE (NCNN)", "Vulkan/NCNN Implementation of RIFE", "rife-ncnn", false);

View File

@@ -83,7 +83,7 @@ namespace Flowframes
{
inPath = "";
outPath = "";
ai = Networks.networks[0];
ai = Implementations.networks[0];
inFpsDetected = new Fraction();
inFps = new Fraction();
interpFactor = 0;
@@ -112,7 +112,7 @@ namespace Flowframes
{
case "INPATH": inPath = entry.Value; break;
case "OUTPATH": outPath = entry.Value; break;
case "AI": ai = Networks.GetAi(entry.Value); break;
case "AI": ai = Implementations.GetAi(entry.Value); break;
case "INFPSDETECTED": inFpsDetected = new Fraction(entry.Value); break;
case "INFPS": inFps = new Fraction(entry.Value); break;
case "OUTFPS": outFps = new Fraction(entry.Value); break;

View File

@@ -184,7 +184,7 @@ namespace Flowframes
inputTbox.Text = entry.inPath;
outputTbox.Text = entry.outPath;
interpFactorCombox.Text = entry.interpFactor.ToString();
aiCombox.SelectedIndex = Networks.networks.IndexOf(entry.ai);
aiCombox.SelectedIndex = Implementations.networks.IndexOf(entry.ai);
SetOutMode(entry.outMode);
}
@@ -262,8 +262,9 @@ namespace Flowframes
void InitAis()
{
foreach (AI ai in Networks.networks)
foreach (AI ai in Implementations.networks)
aiCombox.Items.Add(ai.friendlyName + " - " + ai.description);
ConfigParser.LoadComboxIndex(aiCombox);
}
@@ -343,7 +344,7 @@ namespace Flowframes
AI GetAi()
{
return Networks.networks[aiCombox.SelectedIndex];
return Implementations.networks[aiCombox.SelectedIndex];
}
void inputTbox_DragEnter(object sender, DragEventArgs e) { e.Effect = DragDropEffects.Copy; }

View File

@@ -191,7 +191,7 @@ namespace Flowframes.IO
{
List<string> modelPaths = new List<string>();
foreach (AI ai in Networks.networks)
foreach (AI ai in Implementations.networks)
{
string aiPkgFolder = Path.Combine(Paths.GetPkgPath(), ai.pkgDir);
ModelCollection aiModels = AiModels.GetModels(ai);

View File

@@ -39,10 +39,10 @@ namespace Flowframes.Main
if (Interpolate.current.ai.aiName.ToUpper().Contains("NCNN"))
safetyBufferFrames = Config.GetInt(Config.Key.autoEncSafeBufferNcnn, 150);
if (Interpolate.current.ai.aiName == Networks.rifeCuda.aiName)
if (Interpolate.current.ai.aiName == Implementations.rifeCuda.aiName)
safetyBufferFrames = Config.GetInt(Config.Key.autoEncSafeBufferRifeCuda, 90);
if (Interpolate.current.ai.aiName == Networks.flavrCuda.aiName)
if (Interpolate.current.ai.aiName == Implementations.flavrCuda.aiName)
safetyBufferFrames = Config.GetInt(Config.Key.autoEncSafeBufferFlavrCuda, 90);
}

View File

@@ -178,16 +178,16 @@ namespace Flowframes
List<Task> tasks = new List<Task>();
if (ai.aiName == Networks.rifeCuda.aiName)
if (ai.aiName == Implementations.rifeCuda.aiName)
tasks.Add(AiProcess.RunRifeCuda(current.framesFolder, current.interpFactor, current.model.dir));
if (ai.aiName == Networks.rifeNcnn.aiName)
if (ai.aiName == Implementations.rifeNcnn.aiName)
tasks.Add(AiProcess.RunRifeNcnn(current.framesFolder, outpath, (int)current.interpFactor, current.model.dir));
if (ai.aiName == Networks.flavrCuda.aiName)
if (ai.aiName == Implementations.flavrCuda.aiName)
tasks.Add(AiProcess.RunFlavrCuda(current.framesFolder, current.interpFactor, current.model.dir));
if (ai.aiName == Networks.dainNcnn.aiName)
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 (currentlyUsingAutoEnc)

View File

@@ -132,7 +132,7 @@ namespace Flowframes
static bool HideMessage (string msg)
{
string[] hiddenMsgs = new string[] { "can produce invalid output", "pixel format" };
string[] hiddenMsgs = new string[] { "can produce invalid output", "pixel format", "provided invalid" };
foreach (string str in hiddenMsgs)
if (msg.MatchesWildcard($"*{str}*"))

View File

@@ -25,7 +25,7 @@ namespace Flowframes
public static int GetPadding ()
{
return (Interpolate.current.ai.aiName == Networks.flavrCuda.aiName) ? 8 : 2; // FLAVR input needs to be divisible by 8
return (Interpolate.current.ai.aiName == Implementations.flavrCuda.aiName) ? 8 : 2; // FLAVR input needs to be divisible by 8
}
public static string GetPadFilter ()

View File

@@ -21,10 +21,10 @@ namespace Flowframes.MiscUtils
canceled = false;
List<AI> ais = new List<AI>();
if (rifeC) ais.Add(Networks.rifeCuda);
if (rifeN) ais.Add(Networks.rifeNcnn);
if (dainN) ais.Add(Networks.dainNcnn);
if (flavrC) ais.Add(Networks.flavrCuda);
if (rifeC) ais.Add(Implementations.rifeCuda);
if (rifeN) ais.Add(Implementations.rifeNcnn);
if (dainN) ais.Add(Implementations.dainNcnn);
if (flavrC) ais.Add(Implementations.flavrCuda);
if (ais.Count < 1)
return;

View File

@@ -110,7 +110,7 @@ namespace Flowframes
try
{
string rifeDir = Path.Combine(Paths.GetPkgPath(), Networks.rifeCuda.pkgDir);
string rifeDir = Path.Combine(Paths.GetPkgPath(), Implementations.rifeCuda.pkgDir);
string script = "rife.py";
if (!File.Exists(Path.Combine(rifeDir, script)))
@@ -153,7 +153,7 @@ namespace Flowframes
Process rifePy = OSUtils.NewProcess(!OSUtils.ShowHiddenCmd());
AiStarted(rifePy, 3500);
SetProgressCheck(Path.Combine(Interpolate.current.tempFolder, outDir), interpFactor);
rifePy.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {Path.Combine(Paths.GetPkgPath(), Networks.rifeCuda.pkgDir).Wrap()} & " +
rifePy.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {Path.Combine(Paths.GetPkgPath(), Implementations.rifeCuda.pkgDir).Wrap()} & " +
$"set CUDA_VISIBLE_DEVICES={Config.Get(Config.Key.torchGpus)} & {Python.GetPyCmd()} {script} {args}";
Logger.Log($"Running RIFE (CUDA){(await InterpolateUtils.UseUhd() ? " (UHD Mode)" : "")}...", false);
Logger.Log("cmd.exe " + rifePy.StartInfo.Arguments, true);
@@ -182,7 +182,7 @@ namespace Flowframes
try
{
string flavDir = Path.Combine(Paths.GetPkgPath(), Networks.flavrCuda.pkgDir);
string flavDir = Path.Combine(Paths.GetPkgPath(), Implementations.flavrCuda.pkgDir);
string script = "flavr.py";
if (!File.Exists(Path.Combine(flavDir, script)))
@@ -210,7 +210,7 @@ namespace Flowframes
Process flavrPy = OSUtils.NewProcess(!OSUtils.ShowHiddenCmd());
AiStarted(flavrPy, 4500);
SetProgressCheck(Path.Combine(Interpolate.current.tempFolder, outDir), interpFactor);
flavrPy.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {Path.Combine(Paths.GetPkgPath(), Networks.flavrCuda.pkgDir).Wrap()} & " +
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}";
Logger.Log($"Running FLAVR (CUDA)...", false);
Logger.Log("cmd.exe " + flavrPy.StartInfo.Arguments, true);
@@ -291,7 +291,7 @@ namespace Flowframes
string uhdStr = await InterpolateUtils.UseUhd() ? "-u" : "";
string ttaStr = Config.GetBool(Config.Key.rifeNcnnUseTta, false) ? "-x" : "";
rifeNcnn.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {Path.Combine(Paths.GetPkgPath(), Networks.rifeNcnn.pkgDir).Wrap()} & rife-ncnn-vulkan.exe " +
rifeNcnn.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {Path.Combine(Paths.GetPkgPath(), Implementations.rifeNcnn.pkgDir).Wrap()} & rife-ncnn-vulkan.exe " +
$" -v -i {inPath.Wrap()} -o {outPath.Wrap()} -m {mdl.ToLower()} {ttaStr} {uhdStr} -g {Config.Get(Config.Key.ncnnGpus)} -f {GetNcnnPattern()} -j {GetNcnnThreads()}";
Logger.Log("cmd.exe " + rifeNcnn.StartInfo.Arguments, true);
@@ -332,7 +332,7 @@ namespace Flowframes
public static async Task RunDainNcnnProcess (string framesPath, string outPath, float factor, string mdl, int tilesize)
{
string dainDir = Path.Combine(Paths.GetPkgPath(), Networks.dainNcnn.pkgDir);
string dainDir = Path.Combine(Paths.GetPkgPath(), Implementations.dainNcnn.pkgDir);
Directory.CreateDirectory(outPath);
Process dain = OSUtils.NewProcess(!OSUtils.ShowHiddenCmd());
AiStarted(dain, 1500);
@@ -423,7 +423,7 @@ namespace Flowframes
if (!hasShownError && line.ToLower().Contains("error(s) in loading state_dict"))
{
hasShownError = true;
string msg = (Interpolate.current.ai.aiName == Networks.flavrCuda.aiName) ? "\n\nFor FLAVR, you need to select the correct model for each scale!" : "";
string msg = (Interpolate.current.ai.aiName == Implementations.flavrCuda.aiName) ? "\n\nFor FLAVR, you need to select the correct model for each scale!" : "";
InterpolateUtils.ShowMessage($"Error loading the AI model!\n\n{line}{msg}", "Error");
}
@@ -448,7 +448,7 @@ namespace Flowframes
if (!hasShownError && err && line.Contains("vkAllocateMemory failed"))
{
hasShownError = true;
bool usingDain = (Interpolate.current.ai.aiName == Networks.dainNcnn.aiName);
bool usingDain = (Interpolate.current.ai.aiName == Implementations.dainNcnn.aiName);
string msg = usingDain ? "\n\nTry reducing the tile size in the AI settings." : "\n\nTry a lower resolution (Settings -> Max Video Size).";
InterpolateUtils.ShowMessage($"Vulkan ran out of memory!\n\n{line}{msg}", "Error");
}

View File

@@ -145,7 +145,7 @@ namespace Flowframes.OS
if (!Config.GetBool("fetchModelsFromRepo", false))
return;
foreach (AI ai in Networks.networks)
foreach (AI ai in Implementations.networks)
{
try
{

View File

@@ -41,7 +41,7 @@ namespace Flowframes
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
Networks.Init();
Implementations.Init();
Task.Run(() => DiskSpaceCheckLoop());
fileArgs = Environment.GetCommandLineArgs().Where(a => a[0] != '-' && File.Exists(a)).ToList().Skip(1).ToArray();
args = Environment.GetCommandLineArgs().Where(a => a[0] == '-').Select(x => x.Trim().Substring(1).ToLowerInvariant()).ToArray();