2021-08-23 16:50:18 +02:00
|
|
|
|
using Flowframes.IO;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Flowframes.Data
|
|
|
|
|
|
{
|
2022-05-31 22:17:22 +02:00
|
|
|
|
public class AI
|
2021-08-23 16:50:18 +02:00
|
|
|
|
{
|
2022-05-31 22:17:22 +02:00
|
|
|
|
public enum AiBackend { Pytorch, Ncnn, Tensorflow, Other }
|
|
|
|
|
|
public AiBackend Backend { get; set; } = AiBackend.Pytorch;
|
2022-07-21 10:08:53 +02:00
|
|
|
|
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 PkgDir { get { return NameInternal.Replace("_", "-").ToLower(); } }
|
2022-05-31 22:17:22 +02:00
|
|
|
|
public enum InterpFactorSupport { Fixed, AnyPowerOfTwo, AnyInteger, AnyFloat }
|
|
|
|
|
|
public InterpFactorSupport FactorSupport { get; set; } = InterpFactorSupport.Fixed;
|
|
|
|
|
|
public int[] SupportedFactors { get; set; } = new int[0];
|
|
|
|
|
|
public bool Piped { get; set; } = false;
|
2021-08-23 16:50:18 +02:00
|
|
|
|
|
2022-07-21 09:30:59 +02:00
|
|
|
|
public string LogFilename { get { return PkgDir + "-log"; } }
|
2022-07-20 18:10:31 +02:00
|
|
|
|
|
2022-07-21 10:08:53 +02:00
|
|
|
|
public AI(AiBackend backend, string aiName, InterpFactorSupport factorSupport = InterpFactorSupport.Fixed, int[] supportedFactors = null)
|
2021-08-23 16:50:18 +02:00
|
|
|
|
{
|
2022-05-31 22:17:22 +02:00
|
|
|
|
Backend = backend;
|
2022-07-21 10:08:53 +02:00
|
|
|
|
NameInternal = aiName;
|
2022-05-31 22:17:22 +02:00
|
|
|
|
SupportedFactors = supportedFactors;
|
|
|
|
|
|
FactorSupport = factorSupport;
|
2022-07-21 10:08:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string GetImplemString ()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Backend == AiBackend.Pytorch)
|
|
|
|
|
|
return $"CUDA/Pytorch Implementation";
|
|
|
|
|
|
|
|
|
|
|
|
if(Backend == AiBackend.Ncnn)
|
|
|
|
|
|
return $"Vulkan/NCNN{(Piped ? "/VapourSynth" : "")} Implementation";
|
|
|
|
|
|
|
|
|
|
|
|
if (Backend == AiBackend.Tensorflow)
|
|
|
|
|
|
return $"Tensorflow Implementation";
|
|
|
|
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string GetFrameworkString()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Backend == AiBackend.Pytorch)
|
|
|
|
|
|
return $"CUDA";
|
|
|
|
|
|
|
|
|
|
|
|
if (Backend == AiBackend.Ncnn)
|
|
|
|
|
|
return $"NCNN{(Piped ? "/VS" : "")}";
|
|
|
|
|
|
|
|
|
|
|
|
if (Backend == AiBackend.Tensorflow)
|
|
|
|
|
|
return $"TF";
|
2022-07-04 10:14:31 +02:00
|
|
|
|
|
2022-07-21 10:08:53 +02:00
|
|
|
|
return "Custom";
|
2021-08-23 16:50:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|