RIFE Model selection GUI, removed tilesize related code

This commit is contained in:
N00MKRAD
2021-01-13 23:05:23 +01:00
parent 8d2aa66cf7
commit 62acc84876
8 changed files with 35 additions and 95 deletions

View File

@@ -15,10 +15,9 @@ namespace Flowframes.Data
public string description;
public FlowPackage pkg;
public int minPkgVer;
public bool supportsTiling;
public bool supportsAnyExp;
public AI(string aiNameArg, string friendlyNameArg, string descArg, FlowPackage pkgArg, int minPkgVerForThisBuild, bool supportsTilingArg, bool supportsAnyExpArg)
public AI(string aiNameArg, string friendlyNameArg, string descArg, FlowPackage pkgArg, int minPkgVerForThisBuild, bool supportsAnyExpArg)
{
aiName = aiNameArg;
aiNameShort = aiNameArg.Split(' ')[0];
@@ -27,7 +26,6 @@ namespace Flowframes.Data
description = descArg;
pkg = pkgArg;
minPkgVer = minPkgVerForThisBuild;
supportsTiling = supportsTilingArg;
supportsAnyExp = supportsAnyExpArg;
}
}

View File

@@ -18,7 +18,7 @@ namespace Flowframes
public float outFps;
public int interpFactor;
public Interpolate.OutMode outMode;
public int tilesize;
public string model;
public string tempFolder;
public string framesFolder;
@@ -28,7 +28,7 @@ namespace Flowframes
public Size inputResolution;
public Size scaledResolution;
public InterpSettings(string inPathArg, string outPathArg, AI aiArg, float inFpsArg, int interpFactorArg, Interpolate.OutMode outModeArg, int tilesizeArg = 512)
public InterpSettings(string inPathArg, string outPathArg, AI aiArg, float inFpsArg, int interpFactorArg, Interpolate.OutMode outModeArg, string modelArg)
{
inPath = inPathArg;
outPath = outPathArg;
@@ -37,7 +37,7 @@ namespace Flowframes
interpFactor = interpFactorArg;
outFps = inFpsArg * interpFactorArg;
outMode = outModeArg;
tilesize = tilesizeArg;
model = modelArg;
try
{

View File

@@ -6,10 +6,8 @@ namespace Flowframes.Data
{
class Networks
{
public static AI rifeCuda = new AI("RIFE_CUDA", "RIFE", "CUDA/Pytorch Implementation of RIFE", Packages.rifeCuda, 2, false, true);
public static AI rifeNcnn = new AI("RIFE_NCNN", "RIFE (NCNN)", "Vulkan/NCNN Implementation of RIFE", Packages.rifeNcnn, 1, false, false);
public static AI dainNcnn = new AI("DAIN_NCNN", "DAIN (NCNN)", "Vulkan/NCNN Implementation of DAIN", Packages.dainNcnn, 0, true, true);
public static AI cainNcnn = new AI("CAIN_NCNN", "CAIN (NCNN)", "Vulkan/NCNN Implementation of CAIN", Packages.cainNcnn, 0, true, false);
public static AI rifeCuda = new AI("RIFE_CUDA", "RIFE", "CUDA/Pytorch Implementation of RIFE", Packages.rifeCuda, 2, true);
public static AI rifeNcnn = new AI("RIFE_NCNN", "RIFE (NCNN)", "Vulkan/NCNN Implementation of RIFE", Packages.rifeNcnn, 1, false);
public static List<AI> networks = new List<AI>();
@@ -18,8 +16,6 @@ namespace Flowframes.Data
networks.Clear();
networks.Add(rifeCuda);
networks.Add(rifeNcnn);
networks.Add(dainNcnn);
//networks.Add(cainNcnn);
}
}
}

76
Code/Form1.Designer.cs generated
View File

@@ -31,7 +31,7 @@
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.titleLabel = new System.Windows.Forms.Label();
this.tilesize = new System.Windows.Forms.ComboBox();
this.aiModel = new System.Windows.Forms.ComboBox();
this.aiCombox = new System.Windows.Forms.ComboBox();
this.label13 = new System.Windows.Forms.Label();
this.outModeCombox = new System.Windows.Forms.ComboBox();
@@ -78,7 +78,6 @@
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.updateBtn = new HTAlt.WinForms.HTButton();
this.queueBtn = new HTAlt.WinForms.HTButton();
this.panel7 = new System.Windows.Forms.Panel();
this.pictureBox4 = new System.Windows.Forms.PictureBox();
this.pictureBox3 = new System.Windows.Forms.PictureBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
@@ -104,7 +103,6 @@
this.label15 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.interpOptsTab = new System.Windows.Forms.TabPage();
this.tilesizeNotAvailLabel = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.browseOutBtn = new HTAlt.WinForms.HTButton();
this.browseInputFileBtn = new HTAlt.WinForms.HTButton();
@@ -149,26 +147,22 @@
this.titleLabel.TabIndex = 0;
this.titleLabel.Text = "Flowframes Video Interpolator";
//
// tilesize
// aiModel
//
this.tilesize.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.tilesize.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.tilesize.ForeColor = System.Drawing.Color.White;
this.tilesize.FormattingEnabled = true;
this.tilesize.Items.AddRange(new object[] {
"384",
"512",
"768",
"1024",
"1536",
"2048",
"3072",
"4096"});
this.tilesize.Location = new System.Drawing.Point(281, 127);
this.tilesize.Name = "tilesize";
this.tilesize.Size = new System.Drawing.Size(125, 23);
this.tilesize.TabIndex = 25;
this.tilesize.TextChanged += new System.EventHandler(this.tilesize_TextChanged);
this.aiModel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.aiModel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.aiModel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.aiModel.ForeColor = System.Drawing.Color.White;
this.aiModel.FormattingEnabled = true;
this.aiModel.Items.AddRange(new object[] {
"RIFE 1.5 - Optimized for general content",
"RIFE 1.6 - Optimized for general and UHD content",
"RIFE 1.7 - Optimized for 2D animation (Recommended)",
"RIFE 1.8 - Optimized for 2D animation and general content"});
this.aiModel.Location = new System.Drawing.Point(281, 127);
this.aiModel.Name = "aiModel";
this.aiModel.Size = new System.Drawing.Size(200, 23);
this.aiModel.TabIndex = 25;
//
// aiCombox
//
@@ -234,9 +228,9 @@
this.label8.Location = new System.Drawing.Point(11, 131);
this.label8.Margin = new System.Windows.Forms.Padding(8, 0, 3, 0);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(177, 13);
this.label8.Size = new System.Drawing.Size(49, 13);
this.label8.TabIndex = 13;
this.label8.Text = "Tile Size (Reduce if VRAM runs out)";
this.label8.Text = "AI Model";
//
// label7
//
@@ -728,16 +722,6 @@
this.queueBtn.UseVisualStyleBackColor = false;
this.queueBtn.Click += new System.EventHandler(this.queueBtn_Click);
//
// panel7
//
this.panel7.BackgroundImage = global::Flowframes.Properties.Resources.baseline_create_white_18dp_semiTransparent;
this.panel7.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.panel7.Location = new System.Drawing.Point(412, 128);
this.panel7.Name = "panel7";
this.panel7.Size = new System.Drawing.Size(21, 21);
this.panel7.TabIndex = 60;
this.toolTip1.SetToolTip(this.panel7, "Allows custom input.");
//
// pictureBox4
//
this.pictureBox4.BackgroundImage = global::Flowframes.Properties.Resources.questmark_72px_bordeer;
@@ -764,13 +748,11 @@
//
this.pictureBox1.BackgroundImage = global::Flowframes.Properties.Resources.questmark_72px_bordeer;
this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.pictureBox1.Location = new System.Drawing.Point(194, 128);
this.pictureBox1.Location = new System.Drawing.Point(66, 128);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(29, 21);
this.pictureBox1.TabIndex = 28;
this.pictureBox1.TabStop = false;
this.toolTip1.SetToolTip(this.pictureBox1, "Splits frames into tiles during processing. Use lower values for DAIN and very hi" +
"gh values (2048 should work on GPUs with 4 GB VRAM or more) for CAIN.");
//
// info1
//
@@ -1074,7 +1056,6 @@
//
this.interpOptsTab.AllowDrop = true;
this.interpOptsTab.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.interpOptsTab.Controls.Add(this.tilesizeNotAvailLabel);
this.interpOptsTab.Controls.Add(this.label1);
this.interpOptsTab.Controls.Add(this.browseOutBtn);
this.interpOptsTab.Controls.Add(this.browseInputFileBtn);
@@ -1085,7 +1066,7 @@
this.interpOptsTab.Controls.Add(this.inputTbox);
this.interpOptsTab.Controls.Add(this.outputTbox);
this.interpOptsTab.Controls.Add(this.interpFactorCombox);
this.interpOptsTab.Controls.Add(this.tilesize);
this.interpOptsTab.Controls.Add(this.aiModel);
this.interpOptsTab.Controls.Add(this.fpsInTbox);
this.interpOptsTab.Controls.Add(this.fpsOutTbox);
this.interpOptsTab.Controls.Add(this.label5);
@@ -1096,7 +1077,6 @@
this.interpOptsTab.Controls.Add(this.label8);
this.interpOptsTab.Controls.Add(this.label9);
this.interpOptsTab.Controls.Add(this.outModeCombox);
this.interpOptsTab.Controls.Add(this.panel7);
this.interpOptsTab.Controls.Add(this.pictureBox4);
this.interpOptsTab.Controls.Add(this.pictureBox3);
this.interpOptsTab.Controls.Add(this.pictureBox2);
@@ -1111,18 +1091,6 @@
this.interpOptsTab.DragDrop += new System.Windows.Forms.DragEventHandler(this.Form1_DragDrop);
this.interpOptsTab.DragEnter += new System.Windows.Forms.DragEventHandler(this.Form1_DragEnter);
//
// tilesizeNotAvailLabel
//
this.tilesizeNotAvailLabel.ForeColor = System.Drawing.Color.Silver;
this.tilesizeNotAvailLabel.Location = new System.Drawing.Point(278, 124);
this.tilesizeNotAvailLabel.Margin = new System.Windows.Forms.Padding(8, 0, 3, 0);
this.tilesizeNotAvailLabel.Name = "tilesizeNotAvailLabel";
this.tilesizeNotAvailLabel.Size = new System.Drawing.Size(203, 31);
this.tilesizeNotAvailLabel.TabIndex = 37;
this.tilesizeNotAvailLabel.Text = "Not available for the selected AI.";
this.tilesizeNotAvailLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.tilesizeNotAvailLabel.Visible = false;
//
// label1
//
this.label1.AutoSize = true;
@@ -1432,7 +1400,7 @@
private System.Windows.Forms.Label statusLabel;
private System.Windows.Forms.ComboBox aiCombox;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.ComboBox tilesize;
private System.Windows.Forms.ComboBox aiModel;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.Button debugExtractFramesBtn;
private System.Windows.Forms.Label label16;
@@ -1473,13 +1441,11 @@
private System.Windows.Forms.TabPage previewTab;
private System.Windows.Forms.PictureBox previewPicturebox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label tilesizeNotAvailLabel;
public HTAlt.WinForms.HTTabControl mainTabControl;
private HTAlt.WinForms.HTButton queueBtn;
private HTAlt.WinForms.HTButton htButton1;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.CheckBox utilsExtractAudioCbox;
private System.Windows.Forms.Panel panel7;
private System.Windows.Forms.Panel panel4;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Panel panel3;

View File

@@ -35,7 +35,7 @@ namespace Flowframes
// Main Tab
UIUtils.InitCombox(interpFactorCombox, 0);
UIUtils.InitCombox(outModeCombox, 0);
UIUtils.InitCombox(tilesize, 4);
UIUtils.InitCombox(aiModel, 2);
// Video Utils
UIUtils.InitCombox(utilsLoopTimesCombox, 0);
UIUtils.InitCombox(utilsSpeedCombox, 0);
@@ -90,7 +90,7 @@ namespace Flowframes
public InterpSettings GetCurrentSettings()
{
SetTab("interpolate");
return new InterpSettings(inputTbox.Text.Trim(), outputTbox.Text.Trim(), GetAi(), fpsInTbox.GetFloat(), interpFactorCombox.GetInt(), GetOutMode(), GetTilesize());
return new InterpSettings(inputTbox.Text.Trim(), outputTbox.Text.Trim(), GetAi(), fpsInTbox.GetFloat(), interpFactorCombox.GetInt(), GetOutMode(), GetModel());
}
public void LoadBatchEntry(InterpSettings entry)
@@ -157,18 +157,14 @@ namespace Flowframes
public void runBtn_Click(object sender, EventArgs e)
{
if (!BatchProcessing.busy) // Don't load values from gui if batch processing is used
{
Interpolate.current = GetCurrentSettings();
}
Interpolate.Start();
}
public int GetTilesize()
public string GetModel()
{
if (GetAi().supportsTiling)
return tilesize.GetInt();
else
return 512;
return aiModel.Text.Split('-')[0].Remove(" ").Remove(".");
}
Interpolate.OutMode GetOutMode()
@@ -254,11 +250,7 @@ namespace Flowframes
private void aiCombox_SelectedIndexChanged(object sender, EventArgs e)
{
tilesize.Visible = GetAi().supportsTiling;
tilesizeNotAvailLabel.Visible = !tilesize.Visible;
interpFactorCombox_SelectedIndexChanged(null, null);
if (GetAi().supportsTiling)
tilesize.Text = Config.GetInt($"tilesize_{GetAi().aiName}").ToString();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
@@ -417,11 +409,5 @@ namespace Flowframes
if (!initialized) return;
aiCombox_SelectedIndexChanged(null, null);
}
private void tilesize_TextChanged(object sender, EventArgs e)
{
if (!initialized || !GetAi().supportsTiling) return;
Config.Set($"tilesize_{GetAi().aiName}", tilesize.GetInt().Clamp(32, 4096).ToString());
}
}
}

View File

@@ -36,7 +36,7 @@ namespace Flowframes
public static async Task Start()
{
canceled = false;
if (!Utils.InputIsValid(current.inPath, current.outPath, current.outFps, current.interpFactor, current.tilesize, current.outMode)) return; // General input checks
if (!Utils.InputIsValid(current.inPath, current.outPath, current.outFps, current.interpFactor, current.outMode)) return; // General input checks
if (!Utils.CheckAiAvailable(current.ai)) return; // Check if selected AI pkg is installed
if (!Utils.CheckDeleteOldTempFolder()) return; // Try to delete temp folder if an old one exists
if(!Utils.CheckPathValid(current.inPath)) return; // Check if input path/file is valid

View File

@@ -30,7 +30,7 @@ namespace Flowframes.Main
Program.mainForm.SetWorking(true);
current = Program.mainForm.GetCurrentSettings();
if (!InterpolateUtils.InputIsValid(current.inPath, current.outPath, current.outFps, current.interpFactor, current.tilesize, current.outMode)) return; // General input checks
if (!InterpolateUtils.InputIsValid(current.inPath, current.outPath, current.outFps, current.interpFactor, current.outMode)) return; // General input checks
if (step.Contains("Extract Scene Changes"))
{
@@ -119,7 +119,6 @@ namespace Flowframes.Main
int targetFrameCount = frames * current.interpFactor;
if (canceled) return;
Program.mainForm.SetStatus("Running AI...");
int tilesize = current.ai.supportsTiling ? Config.GetInt($"tilesize_{current.ai.aiName}") : 512;
await RunAi(current.interpFolder, current.ai, true);
Program.mainForm.SetProgress(0);
}

View File

@@ -175,7 +175,7 @@ namespace Flowframes.Main
return Path.Combine(basePath, Path.GetFileNameWithoutExtension(inPath).StripBadChars().Remove(" ").Trunc(30, false) + "-temp");
}
public static bool InputIsValid(string inDir, string outDir, float fpsOut, int interp, int tilesize, Interpolate.OutMode outMode)
public static bool InputIsValid(string inDir, string outDir, float fpsOut, int interp, Interpolate.OutMode outMode)
{
bool passes = true;
@@ -206,11 +206,6 @@ namespace Flowframes.Main
ShowMessage("Invalid output frame rate - Must be 1-500.");
passes = false;
}
if (passes && tilesize % 32 != 0 || tilesize < 128)
{
ShowMessage("Tile size is not valid - Must be a multiple of 32 and at least 128!");
passes = false;
}
if (!passes)
i.Cancel("Invalid settings detected.", true);
return passes;