Read supported interp factors from Implementation/AI class

This commit is contained in:
n00mkrad
2021-08-15 14:33:03 +02:00
parent d998ef2a6b
commit 3dec8b9093
6 changed files with 24 additions and 16 deletions

View File

@@ -14,16 +14,18 @@ namespace Flowframes.Data
public string friendlyName;
public string description;
public string pkgDir;
public bool supportsAnyExp;
public int[] supportedFactors;
public bool multiPass; // Are multiple passes needed to get to the desired interp factor?
public AI(string aiNameArg, string friendlyNameArg, string descArg, string pkgDirArg, bool supportsAnyExpArg)
public AI(string aiNameArg, string friendlyNameArg, string descArg, string pkgDirArg, int[] factorsArg, bool multiPassArg = false)
{
aiName = aiNameArg;
aiNameShort = aiNameArg.Split(' ')[0].Split('_')[0];
friendlyName = friendlyNameArg;
description = descArg;
pkgDir = pkgDirArg;
supportsAnyExp = supportsAnyExpArg;
supportedFactors = factorsArg;
multiPass = multiPassArg;
}
}
}

View File

@@ -6,11 +6,11 @@ namespace Flowframes.Data
{
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);
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 AI rifeCuda = new AI("RIFE_CUDA", "RIFE", "CUDA/Pytorch Implementation of RIFE (Nvidia Only!)", "rife-cuda", new int[] { 2, 4, 8, 16 });
public static AI rifeNcnn = new AI("RIFE_NCNN", "RIFE (NCNN)", "Vulkan/NCNN Implementation of RIFE", "rife-ncnn", new int[] { 2, 4, 8 }, true);
public static AI flavrCuda = new AI("FLAVR_CUDA", "FLAVR", "Experimental Pytorch Implementation of FLAVR (Nvidia Only!)", "flavr-cuda", new int[] { 2, 4, 8 });
public static AI dainNcnn = new AI("DAIN_NCNN", "DAIN (NCNN)", "Vulkan/NCNN Implementation of DAIN", "dain-ncnn", new int[] { 2, 4, 8 });
public static AI xvfiCuda = new AI("XVFI_CUDA", "XVFI", "CUDA / Pytorch Implementation of XVFI (Nvidia Only!)", "xvfi-cuda", new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 });
public static List<AI> networks = new List<AI>();

View File

@@ -317,10 +317,6 @@
this.interpFactorCombox.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.interpFactorCombox.ForeColor = System.Drawing.Color.White;
this.interpFactorCombox.FormattingEnabled = true;
this.interpFactorCombox.Items.AddRange(new object[] {
"x2",
"x4",
"x8"});
this.interpFactorCombox.Location = new System.Drawing.Point(447, 96);
this.interpFactorCombox.Name = "interpFactorCombox";
this.interpFactorCombox.Size = new System.Drawing.Size(100, 23);

View File

@@ -393,10 +393,13 @@ namespace Flowframes
{
UpdateUiFps();
int guiInterpFactor = interpFactorCombox.GetInt();
if (!initialized)
return;
string aiName = GetAi().aiName.Replace("_", "-");
if (!Program.busy && guiInterpFactor > 2 && !GetAi().supportsAnyExp && Config.GetInt(Config.Key.autoEncMode) > 0 && !Logger.GetLastLine().Contains(aiName))
if (!Program.busy && guiInterpFactor > 2 && GetAi().multiPass && Config.GetInt(Config.Key.autoEncMode) > 0 && !Logger.GetLastLine().Contains(aiName))
Logger.Log($"Warning: {aiName} doesn't natively support 4x/8x and will run multiple times for {guiInterpFactor}x. Auto-Encode will only work on the last run.");
}
@@ -426,6 +429,13 @@ namespace Flowframes
if (string.IsNullOrWhiteSpace(aiCombox.Text) || aiCombox.Text == lastAiComboxStr) return;
lastAiComboxStr = aiCombox.Text;
UpdateAiModelCombox();
interpFactorCombox.Items.Clear();
foreach (int factor in GetAi().supportedFactors)
interpFactorCombox.Items.Add($"x{factor}");
interpFactorCombox.SelectedIndex = 0;
if(initialized)
ConfigParser.SaveComboxIndex(aiCombox);

View File

@@ -396,12 +396,12 @@ namespace Flowframes
string basePath = inPath.GetParentDir();
string outPath = Path.Combine(basePath, outDir);
Directory.CreateDirectory(outPath);
string mdlArgs = File.ReadAllText(Path.Combine(pkgPath, mdlDir, "args.txt"));
string mdlArgs = File.ReadAllText(Path.Combine(pkgPath, mdlDir, "args.ini"));
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);
AiStarted(xvfiPy, 3500);
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}";

View File

@@ -80,7 +80,7 @@ namespace Flowframes.UI
}
catch
{
Logger.Log($"UpdateLastFrameFromInterpOutput: Failed to get progress from '{output}' even though Regex matched!");
Logger.Log($"UpdateLastFrameFromInterpOutput: Failed to get progress from '{output}' even though Regex matched!", true);
}
}