mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-16 16:37:48 +01:00
Better implementation/networks references (all vs available)
This commit is contained in:
@@ -1,39 +1,57 @@
|
||||
using System.Collections.Generic;
|
||||
using Flowframes.Os;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Flowframes.Data
|
||||
{
|
||||
class Implementations
|
||||
{
|
||||
public static AI rifeCuda = new AI(AI.AiBackend.Pytorch, "RIFE_CUDA", "RIFE",
|
||||
public static AI rifeCuda = new AI(AI.AiBackend.Pytorch, "RIFE_CUDA", "RIFE",
|
||||
"CUDA/Pytorch Implementation of RIFE", "rife-cuda", 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", "RIFE (NCNN/VS)",
|
||||
"Vulkan/NCNN/VapourSynth Implementation of RIFE", "rife-ncnn-vs", AI.InterpFactorSupport.AnyFloat, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }) { Piped = true };
|
||||
"Vulkan/NCNN/VapourSynth Implementation of RIFE", "rife-ncnn-vs", 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", "RIFE (NCNN)",
|
||||
public static AI rifeNcnn = new AI(AI.AiBackend.Ncnn, "RIFE_NCNN", "RIFE (NCNN)",
|
||||
"Vulkan/NCNN Implementation of RIFE", "rife-ncnn", 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", "FLAVR",
|
||||
public static AI flavrCuda = new AI(AI.AiBackend.Pytorch, "FLAVR_CUDA", "FLAVR",
|
||||
"Experimental Pytorch Implementation of FLAVR", "flavr-cuda", AI.InterpFactorSupport.Fixed, new int[] { 2, 4, 8 });
|
||||
|
||||
public static AI dainNcnn = new AI(AI.AiBackend.Ncnn, "DAIN_NCNN", "DAIN (NCNN)",
|
||||
public static AI dainNcnn = new AI(AI.AiBackend.Ncnn, "DAIN_NCNN", "DAIN (NCNN)",
|
||||
"Vulkan/NCNN Implementation of DAIN", "dain-ncnn", AI.InterpFactorSupport.AnyFloat, new int[] { 2, 3, 4, 5, 6, 7, 8 });
|
||||
|
||||
public static AI xvfiCuda = new AI(AI.AiBackend.Pytorch, "XVFI_CUDA", "XVFI",
|
||||
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 List<AI> networks = new List<AI> { rifeCuda, rifeNcnnVs, rifeNcnn, flavrCuda, dainNcnn, xvfiCuda };
|
||||
|
||||
public static AI GetAi (string aiName)
|
||||
public static List<AI> NetworksAll
|
||||
{
|
||||
foreach(AI ai in networks)
|
||||
get
|
||||
{
|
||||
return new List<AI> { rifeCuda, rifeNcnnVs, rifeNcnn, flavrCuda, dainNcnn, xvfiCuda };
|
||||
}
|
||||
}
|
||||
|
||||
public static List<AI> NetworksAvailable
|
||||
{
|
||||
get
|
||||
{
|
||||
bool pytorchAvailable = Python.IsPytorchReady();
|
||||
return NetworksAll.Where(x => x.Backend != AI.AiBackend.Pytorch).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public static AI GetAi(string aiName)
|
||||
{
|
||||
foreach (AI ai in NetworksAll)
|
||||
{
|
||||
if (ai.AiName == aiName)
|
||||
return ai;
|
||||
}
|
||||
|
||||
Logger.Log($"AI implementation lookup failed! This should not happen! Please tell the developer! (Implementations.cs)");
|
||||
return networks[0];
|
||||
return NetworksAll[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,7 +192,7 @@ namespace Flowframes
|
||||
inputTbox.Text = entry.inPath;
|
||||
MainUiFunctions.SetOutPath(outputTbox, entry.outPath);
|
||||
interpFactorCombox.Text = entry.interpFactor.ToString();
|
||||
aiCombox.SelectedIndex = Implementations.networks.IndexOf(Implementations.networks.Where(x => x.AiName == entry.ai.AiName).FirstOrDefault());
|
||||
aiCombox.SelectedIndex = Implementations.NetworksAvailable.IndexOf(Implementations.NetworksAvailable.Where(x => x.AiName == entry.ai.AiName).FirstOrDefault());
|
||||
SetOutMode(entry.outMode);
|
||||
}
|
||||
|
||||
@@ -272,19 +272,11 @@ namespace Flowframes
|
||||
{
|
||||
bool pytorchAvailable = Python.IsPytorchReady();
|
||||
|
||||
foreach (AI ai in Implementations.networks)
|
||||
{
|
||||
if (ai.Backend == AI.AiBackend.Pytorch && !pytorchAvailable)
|
||||
{
|
||||
Logger.Log($"AI implementation {ai.FriendlyName} ({ai.Backend}) has not been loaded because Pytorch was not found.", true);
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (AI ai in Implementations.NetworksAvailable)
|
||||
aiCombox.Items.Add(GetAiComboboxName(ai));
|
||||
}
|
||||
|
||||
string lastUsedAiName = Config.Get(Config.Key.lastUsedAiName);
|
||||
aiCombox.SelectedIndex = Implementations.networks.IndexOf(Implementations.networks.Where(x => x.AiName == lastUsedAiName).FirstOrDefault());
|
||||
aiCombox.SelectedIndex = Implementations.NetworksAvailable.IndexOf(Implementations.NetworksAvailable.Where(x => x.AiName == lastUsedAiName).FirstOrDefault());
|
||||
if (aiCombox.SelectedIndex < 0) aiCombox.SelectedIndex = 0;
|
||||
Config.Set(Config.Key.lastUsedAiName, GetAi().AiName);
|
||||
|
||||
@@ -381,14 +373,14 @@ namespace Flowframes
|
||||
|
||||
public AI GetAi()
|
||||
{
|
||||
foreach(AI ai in Implementations.networks)
|
||||
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.networks[0];
|
||||
return Implementations.NetworksAvailable[0];
|
||||
|
||||
//return Implementations.networks[aiCombox.SelectedIndex];
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ namespace Flowframes.IO
|
||||
{
|
||||
List<string> modelPaths = new List<string>();
|
||||
|
||||
foreach (AI ai in Implementations.networks)
|
||||
foreach (AI ai in Implementations.NetworksAll)
|
||||
{
|
||||
string aiPkgFolder = Path.Combine(Paths.GetPkgPath(), ai.PkgDir);
|
||||
ModelCollection aiModels = AiModels.GetModels(ai);
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace Flowframes.Os
|
||||
if (!Config.GetBool("fetchModelsFromRepo", false))
|
||||
return;
|
||||
|
||||
foreach (AI ai in Implementations.networks)
|
||||
foreach (AI ai in Implementations.NetworksAll)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user