diff --git a/Code/Data/AI.cs b/Code/Data/AI.cs index 6155e33..a36f826 100644 --- a/Code/Data/AI.cs +++ b/Code/Data/AI.cs @@ -1,6 +1,8 @@ using Flowframes.IO; +using Flowframes.MiscUtils; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -13,8 +15,9 @@ namespace Flowframes.Data public AiBackend Backend { get; set; } = AiBackend.Pytorch; public string NameInternal { get; set; } = ""; public string NameShort { get { return NameInternal.Split(' ')[0].Split('_')[0]; } } - public string FriendlyName { get { return $"{NameShort} ({GetFrameworkString()})"; } } - public string Description { get { return $"{GetImplemString()} of {NameShort}{(Backend == AiBackend.Pytorch ? " (Nvidia Only!)" : "")}"; } } + public string NameLong { get; set; } = ""; + public string FriendlyName { get { return $"{NameShort} ({GetFrameworkString(Backend)})"; } } + public string Description { get { return $"{GetImplemString(Backend)} of {NameShort}{(Backend == AiBackend.Pytorch ? " (Nvidia Only!)" : "")}"; } } public string PkgDir { get { return NameInternal.Replace("_", "-").ToLower(); } } public enum InterpFactorSupport { Fixed, AnyPowerOfTwo, AnyInteger, AnyFloat } public InterpFactorSupport FactorSupport { get; set; } = InterpFactorSupport.Fixed; @@ -23,40 +26,80 @@ namespace Flowframes.Data public string LogFilename { get { return PkgDir + "-log"; } } - public AI(AiBackend backend, string aiName, InterpFactorSupport factorSupport = InterpFactorSupport.Fixed, int[] supportedFactors = null) + public AI(AiBackend backend, string aiName, string longName, InterpFactorSupport factorSupport = InterpFactorSupport.Fixed, int[] supportedFactors = null) { Backend = backend; NameInternal = aiName; + NameLong = longName; SupportedFactors = supportedFactors; FactorSupport = factorSupport; } - private string GetImplemString () + public string GetVerboseInfo () { - if (Backend == AiBackend.Pytorch) + return $"Name:\n{NameShort}\n\n" + + $"Full Name:\n{NameLong}\n\n" + + $"Inference Framework:\n{FormatUtils.CapsIfShort(Backend.ToString(), 5)}\n\n" + + $"Hardware Acceleration:\n{GetHwAccelString(Backend)}\n\n" + + $"Supported Interpolation Factors:\n{GetFactorsString(FactorSupport)}\n\n" + + $"Requires Frame Extraction:\n{(Piped ? "No" : "Yes")}\n\n" + + $"Package Directory/Size:\n{PkgDir} ({FormatUtils.Bytes(IoUtils.GetDirSize(Path.Combine(Paths.GetPkgPath(), PkgDir), true))})"; + } + + private string GetImplemString (AiBackend backend) + { + if (backend == AiBackend.Pytorch) return $"CUDA/Pytorch Implementation"; - if(Backend == AiBackend.Ncnn) + if(backend == AiBackend.Ncnn) return $"Vulkan/NCNN{(Piped ? "/VapourSynth" : "")} Implementation"; - if (Backend == AiBackend.Tensorflow) + if (backend == AiBackend.Tensorflow) return $"Tensorflow Implementation"; return ""; } - private string GetFrameworkString() + private string GetFrameworkString(AiBackend backend) { - if (Backend == AiBackend.Pytorch) + if (backend == AiBackend.Pytorch) return $"CUDA"; - if (Backend == AiBackend.Ncnn) + if (backend == AiBackend.Ncnn) return $"NCNN{(Piped ? "/VS" : "")}"; - if (Backend == AiBackend.Tensorflow) + if (backend == AiBackend.Tensorflow) return $"TF"; return "Custom"; } + + private string GetHwAccelString (AiBackend backend) + { + if (Backend == AiBackend.Pytorch) + return $"GPU (Nvidia CUDA)"; + + if (Backend == AiBackend.Ncnn) + return $"GPU (Vulkan)"; + + return "Unknown"; + } + + private string GetFactorsString (InterpFactorSupport factorSupport) + { + if (factorSupport == InterpFactorSupport.Fixed) + return $"{string.Join(", ", SupportedFactors.Select(x => $"{x}x"))}"; + + if (factorSupport == InterpFactorSupport.AnyPowerOfTwo) + return "Any powers of 2 (2/4/8/16 etc.)"; + + if (factorSupport == InterpFactorSupport.AnyInteger) + return "Any integer (whole number)"; + + if (factorSupport == InterpFactorSupport.AnyFloat) + return "Any, including fractional factors"; + + return "Unknown"; + } } } diff --git a/Code/Data/Implementations.cs b/Code/Data/Implementations.cs index 17cfbab..2a8ee4b 100644 --- a/Code/Data/Implementations.cs +++ b/Code/Data/Implementations.cs @@ -6,20 +6,26 @@ namespace Flowframes.Data { class Implementations { - public static AI rifeCuda = new AI(AI.AiBackend.Pytorch, "RIFE_CUDA", AI.InterpFactorSupport.AnyInteger, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }); + private static readonly string rifeLong = "Real-Time Intermediate Flow Estimation"; + private static readonly string flavrLong = "Flow-Agnostic Video Representations"; + private static readonly string dainLong = "Depth-Aware Video Frame Interpolation"; + private static readonly string xvfiLong = "eXtreme Video Frame Interpolation"; + private static readonly string ifrnetLong = "Intermediate Feature Refine Network"; - public static AI rifeNcnnVs = new AI(AI.AiBackend.Ncnn, "RIFE_NCNN_VS", AI.InterpFactorSupport.AnyFloat, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }) + public static AI rifeCuda = new AI(AI.AiBackend.Pytorch, "RIFE_CUDA", rifeLong, AI.InterpFactorSupport.AnyInteger, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }); + + public static AI rifeNcnnVs = new AI(AI.AiBackend.Ncnn, "RIFE_NCNN_VS", rifeLong, AI.InterpFactorSupport.AnyFloat, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }) { Piped = true }; - public static AI rifeNcnn = new AI(AI.AiBackend.Ncnn, "RIFE_NCNN", AI.InterpFactorSupport.AnyFloat, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }); + public static AI rifeNcnn = new AI(AI.AiBackend.Ncnn, "RIFE_NCNN", rifeLong, AI.InterpFactorSupport.AnyFloat, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - public static AI flavrCuda = new AI(AI.AiBackend.Pytorch, "FLAVR_CUDA", AI.InterpFactorSupport.Fixed, new int[] { 2, 4, 8 }); + public static AI flavrCuda = new AI(AI.AiBackend.Pytorch, "FLAVR_CUDA", flavrLong, AI.InterpFactorSupport.Fixed, new int[] { 2, 4, 8 }); - public static AI dainNcnn = new AI(AI.AiBackend.Ncnn, "DAIN_NCNN", AI.InterpFactorSupport.AnyFloat, new int[] { 2, 3, 4, 5, 6, 7, 8 }); + public static AI dainNcnn = new AI(AI.AiBackend.Ncnn, "DAIN_NCNN", dainLong, AI.InterpFactorSupport.AnyFloat, new int[] { 2, 3, 4, 5, 6, 7, 8 }); - public static AI xvfiCuda = new AI(AI.AiBackend.Pytorch, "XVFI_CUDA", AI.InterpFactorSupport.AnyInteger, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }); + public static AI xvfiCuda = new AI(AI.AiBackend.Pytorch, "XVFI_CUDA", xvfiLong, 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", AI.InterpFactorSupport.Fixed, new int[] { 2 }); + public static AI ifrnetNcnn = new AI(AI.AiBackend.Ncnn, "IFRNet_NCNN", ifrnetLong, AI.InterpFactorSupport.Fixed, new int[] { 2 }); public static List NetworksAll { diff --git a/Code/Flowframes.csproj b/Code/Flowframes.csproj index bfa2d92..4e1d2c9 100644 --- a/Code/Flowframes.csproj +++ b/Code/Flowframes.csproj @@ -372,6 +372,12 @@ DebugForm.cs + + Form + + + MessageForm.cs + Form @@ -474,6 +480,9 @@ DebugForm.cs + + MessageForm.cs + ModelDownloadForm.cs diff --git a/Code/Form1.Designer.cs b/Code/Form1.Designer.cs index 76e6957..6edd22c 100644 --- a/Code/Form1.Designer.cs +++ b/Code/Form1.Designer.cs @@ -90,6 +90,7 @@ this.label15 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label(); this.interpOptsTab = new System.Windows.Forms.TabPage(); + this.aiInfoBtn = new HTAlt.WinForms.HTButton(); this.outSpeedCombox = new System.Windows.Forms.ComboBox(); this.completionActionPanel = new System.Windows.Forms.Panel(); this.completionAction = new System.Windows.Forms.ComboBox(); @@ -914,6 +915,7 @@ // 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.aiInfoBtn); this.interpOptsTab.Controls.Add(this.pictureBox5); this.interpOptsTab.Controls.Add(this.outSpeedCombox); this.interpOptsTab.Controls.Add(this.completionActionPanel); @@ -953,6 +955,20 @@ this.interpOptsTab.DragDrop += new System.Windows.Forms.DragEventHandler(this.Form1_DragDrop); this.interpOptsTab.DragEnter += new System.Windows.Forms.DragEventHandler(this.Form1_DragEnter); // + // aiInfoBtn + // + this.aiInfoBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.aiInfoBtn.FlatAppearance.BorderSize = 0; + this.aiInfoBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.aiInfoBtn.ForeColor = System.Drawing.Color.White; + this.aiInfoBtn.Location = new System.Drawing.Point(689, 7); + this.aiInfoBtn.Name = "aiInfoBtn"; + this.aiInfoBtn.Size = new System.Drawing.Size(206, 23); + this.aiInfoBtn.TabIndex = 45; + this.aiInfoBtn.Text = "About This Implementation..."; + this.aiInfoBtn.UseVisualStyleBackColor = false; + this.aiInfoBtn.Click += new System.EventHandler(this.aiInfoBtn_Click); + // // outSpeedCombox // this.outSpeedCombox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); @@ -1824,6 +1840,7 @@ private System.Windows.Forms.Label label25; private System.Windows.Forms.ComboBox outSpeedCombox; private System.Windows.Forms.PictureBox pictureBox5; + private HTAlt.WinForms.HTButton aiInfoBtn; } } diff --git a/Code/Form1.cs b/Code/Form1.cs index 628956d..28eb611 100644 --- a/Code/Form1.cs +++ b/Code/Form1.cs @@ -376,16 +376,21 @@ namespace Flowframes public AI GetAi() { - foreach(AI ai in Implementations.NetworksAll) + try { - if (GetAiComboboxName(ai) == aiCombox.Text) - return ai; + foreach (AI ai in Implementations.NetworksAll) + { + if (GetAiComboboxName(ai) == aiCombox.Text) + return ai; + } + + Logger.Log($"AI implementation lookup failed! This should not happen! Please tell the developer!"); + return Implementations.NetworksAvailable[0]; + } + catch + { + return null; } - - Logger.Log($"AI implementation lookup failed! This should not happen! Please tell the developer!"); - return Implementations.NetworksAvailable[0]; - - //return Implementations.networks[aiCombox.SelectedIndex]; } void inputTbox_DragEnter(object sender, DragEventArgs e) { e.Effect = DragDropEffects.Copy; } @@ -747,5 +752,13 @@ namespace Flowframes ValidateFactor(); fpsOutTbox.Text = $"{inFps * interpFactorCombox.GetFloat()} FPS"; } + + private void aiInfoBtn_Click(object sender, EventArgs e) + { + var ai = GetAi(); + + if(ai != null) + UiUtils.ShowMessageBox(ai.GetVerboseInfo(), UiUtils.MessageType.Message); + } } } \ No newline at end of file diff --git a/Code/Forms/MessageForm.Designer.cs b/Code/Forms/MessageForm.Designer.cs new file mode 100644 index 0000000..899beff --- /dev/null +++ b/Code/Forms/MessageForm.Designer.cs @@ -0,0 +1,85 @@ +namespace Flowframes.Forms +{ + partial class MessageForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textLabel = new System.Windows.Forms.Label(); + this.okBtn = new HTAlt.WinForms.HTButton(); + this.SuspendLayout(); + // + // textLabel + // + this.textLabel.AutoSize = true; + this.textLabel.ForeColor = System.Drawing.Color.White; + this.textLabel.Location = new System.Drawing.Point(15, 15); + this.textLabel.Margin = new System.Windows.Forms.Padding(8, 0, 3, 0); + this.textLabel.Name = "textLabel"; + this.textLabel.Size = new System.Drawing.Size(0, 13); + this.textLabel.TabIndex = 8; + // + // okBtn + // + this.okBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.okBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.okBtn.FlatAppearance.BorderSize = 0; + this.okBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.okBtn.ForeColor = System.Drawing.Color.White; + this.okBtn.Location = new System.Drawing.Point(232, 126); + this.okBtn.Name = "okBtn"; + this.okBtn.Size = new System.Drawing.Size(100, 23); + this.okBtn.TabIndex = 46; + this.okBtn.Text = "OK"; + this.okBtn.UseVisualStyleBackColor = false; + this.okBtn.Click += new System.EventHandler(this.okBtn_Click); + // + // MessageForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(32)))), ((int)(((byte)(32))))); + this.ClientSize = new System.Drawing.Size(344, 161); + this.Controls.Add(this.okBtn); + this.Controls.Add(this.textLabel); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "MessageForm"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Load += new System.EventHandler(this.MessageForm_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label textLabel; + private HTAlt.WinForms.HTButton okBtn; + } +} \ No newline at end of file diff --git a/Code/Forms/MessageForm.cs b/Code/Forms/MessageForm.cs new file mode 100644 index 0000000..99f624a --- /dev/null +++ b/Code/Forms/MessageForm.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Flowframes.Forms +{ + public partial class MessageForm : Form + { + private string _text = ""; + private string _title = ""; + + public MessageForm(string text, string title) + { + _text = text; + _title = title; + InitializeComponent(); + } + + private void MessageForm_Load(object sender, EventArgs e) + { + Text = _title; + textLabel.Text = _text; + Size labelSize = GetLabelSize(textLabel); + Size = new Size((labelSize.Width + 60).Clamp(360, Program.mainForm.Size.Width), (labelSize.Height + 120).Clamp(200, Program.mainForm.Size.Height)); + CenterToScreen(); + } + + private Size GetLabelSize(Label label) + { + return TextRenderer.MeasureText(label.Text, label.Font, label.ClientSize, TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl); + } + + private void okBtn_Click(object sender, EventArgs e) + { + Close(); + } + } +} diff --git a/Code/Forms/MessageForm.resx b/Code/Forms/MessageForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Code/Forms/MessageForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Code/Main/InterpolateUtils.cs b/Code/Main/InterpolateUtils.cs index 7d773d6..4810d43 100644 --- a/Code/Main/InterpolateUtils.cs +++ b/Code/Main/InterpolateUtils.cs @@ -225,7 +225,7 @@ namespace Flowframes.Main { string enc = FfmpegUtils.GetEnc(FfmpegUtils.GetCodec(I.currentSettings.outMode)); - float maxAv1Fps = 240; + float maxAv1Fps = 480; if (enc.ToLower().Contains("av1") && encodeFps > maxAv1Fps) { diff --git a/Code/MiscUtils/FormatUtils.cs b/Code/MiscUtils/FormatUtils.cs index a058719..0f495b0 100644 --- a/Code/MiscUtils/FormatUtils.cs +++ b/Code/MiscUtils/FormatUtils.cs @@ -183,5 +183,13 @@ namespace Flowframes.MiscUtils return line; } + + public static string CapsIfShort(string codec, int capsIfShorterThan = 5) + { + if (codec.Length < capsIfShorterThan) + return codec.ToUpper(); + else + return codec.ToTitleCase(); + } } } diff --git a/Code/Ui/UiUtils.cs b/Code/Ui/UiUtils.cs index 3ac5a21..687ef8d 100644 --- a/Code/Ui/UiUtils.cs +++ b/Code/Ui/UiUtils.cs @@ -1,4 +1,5 @@ using Flowframes.Data; +using Flowframes.Forms; using Flowframes.IO; using Flowframes.Main; using Flowframes.Os; @@ -91,16 +92,14 @@ namespace Flowframes.Ui return new DialogResult(); } - if (BatchProcessing.busy) - return new DialogResult(); - MessageBoxIcon icon = MessageBoxIcon.Information; if (type == MessageType.Warning) icon = MessageBoxIcon.Warning; else if (type == MessageType.Error) icon = MessageBoxIcon.Error; - DialogResult res = MessageBox.Show(text, $"Flowframes - {type}", MessageBoxButtons.OK, icon, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification); - Program.mainForm.Activate(); - return res; + //DialogResult res = MessageBox.Show(text, $"Flowframes - {type}", MessageBoxButtons.OK, icon, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification); + MessageForm form = new MessageForm(text, type.ToString()); + form.ShowDialog(); + return DialogResult.OK; } public enum MoveDirection { Up = -1, Down = 1 };