mirror of
https://github.com/n00mkrad/flowframes.git
synced 2026-09-01 19:51:28 +02:00
Removed package manager remnants, added FLAVR network (WIP)
This commit is contained in:
@@ -13,16 +13,16 @@ namespace Flowframes.Data
|
||||
public string aiNameShort;
|
||||
public string friendlyName;
|
||||
public string description;
|
||||
public FlowPackage pkg;
|
||||
public string pkgDir;
|
||||
public bool supportsAnyExp;
|
||||
|
||||
public AI(string aiNameArg, string friendlyNameArg, string descArg, FlowPackage pkgArg, bool supportsAnyExpArg)
|
||||
public AI(string aiNameArg, string friendlyNameArg, string descArg, string pkgDirArg, bool supportsAnyExpArg)
|
||||
{
|
||||
aiName = aiNameArg;
|
||||
aiNameShort = aiNameArg.Split(' ')[0].Split('_')[0];
|
||||
friendlyName = friendlyNameArg;
|
||||
description = descArg;
|
||||
pkg = pkgArg;
|
||||
pkgDir = pkgDirArg;
|
||||
supportsAnyExp = supportsAnyExpArg;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Flowframes.IO
|
||||
{
|
||||
public struct FlowPackage
|
||||
{
|
||||
public string friendlyName;
|
||||
public string fileName;
|
||||
public int downloadSizeMb;
|
||||
public string desc;
|
||||
|
||||
public FlowPackage(string friendlyNameStr, string fileNameStr, int downloadSizeMbInt, string description)
|
||||
{
|
||||
friendlyName = friendlyNameStr;
|
||||
fileName = fileNameStr;
|
||||
downloadSizeMb = downloadSizeMbInt;
|
||||
desc = description;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,10 @@ namespace Flowframes.Data
|
||||
{
|
||||
class Networks
|
||||
{
|
||||
public static AI rifeCuda = new AI("RIFE_CUDA", "RIFE", "CUDA/Pytorch Implementation of RIFE (Nvidia Only!)", Packages.rifeCuda, true);
|
||||
public static AI rifeNcnn = new AI("RIFE_NCNN", "RIFE (NCNN)", "Vulkan/NCNN Implementation of RIFE", Packages.rifeNcnn, false);
|
||||
public static AI dainNcnn = new AI("DAIN_NCNN", "DAIN (NCNN)", "Vulkan/NCNN Implementation of DAIN", Packages.dainNcnn, true);
|
||||
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", "RIFE", "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 List<AI> networks = new List<AI>();
|
||||
|
||||
@@ -17,6 +18,7 @@ namespace Flowframes.Data
|
||||
networks.Clear();
|
||||
networks.Add(rifeCuda);
|
||||
networks.Add(rifeNcnn);
|
||||
// networks.Add(flavrCuda);
|
||||
networks.Add(dainNcnn);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
|
||||
|
||||
namespace Flowframes.IO
|
||||
{
|
||||
class Packages
|
||||
{
|
||||
public static FlowPackage dainNcnn = new FlowPackage("DAIN-NCNN (AMD/Nvidia)", "dain-ncnn.7z", 40, "NCNN/Vulkan implementation of DAIN. Very slow and VRAM-hungry.");
|
||||
//public static FlowPackage cainNcnn = new FlowPackage("CAIN-NCNN (AMD/Nvidia)", "cain-ncnn.7z", 75, "NCNN/Vulkan implementation of CAIN. About 8x faster than DAIN and very lightweight on VRAM.");
|
||||
public static FlowPackage rifeCuda = new FlowPackage("RIFE (Nvidia)", "rife-cuda.7z", 50, "Pytorch implementation of RIFE. Very fast (~2x CAIN, >16x DAIN) and not too VRAM-heavy.");
|
||||
public static FlowPackage rifeNcnn = new FlowPackage("RIFE-NCNN (AMD/Nvidia) [EXPERIMENTAL]", "rife-ncnn.7z", 25, "NCNN/Vulkan implementation of RIFE. Similar speed and VRAM usage as CAIN, but can have better quality.");
|
||||
//public static FlowPackage python = new FlowPackage("Python Runtime", "py.7z", 640, "Embedded Python runtime including Pytorch and all other dependencies. Install this if you don't have system Python.");
|
||||
public static FlowPackage audioVideo = new FlowPackage("Audio/Video Tools (Required)", "av.7z", 10, "Utilities for extracting frames, analysing videos, encoding videos and GIFs.");
|
||||
public static FlowPackage licenses = new FlowPackage("Licenses (Required)", "licenses.7z", 1, "License files for redistributed software.");
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,9 @@ namespace Flowframes.IO
|
||||
|
||||
public const string audioSuffix = "audio";
|
||||
|
||||
public const string audioVideoDir = "av";
|
||||
public const string licensesDir = "licenses";
|
||||
|
||||
public static string GetFrameOrderFilename(float factor)
|
||||
{
|
||||
return $"{frameOrderPrefix}-{factor.ToStringDot()}x.ini";
|
||||
|
||||
@@ -233,10 +233,7 @@
|
||||
<DependentUpon>UpdaterForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="IO\ConfigParser.cs" />
|
||||
<Compile Include="Data\FlowPackage.cs" />
|
||||
<Compile Include="IO\ModelDownloader.cs" />
|
||||
<Compile Include="Data\Packages.cs" />
|
||||
<Compile Include="IO\PkgUtils.cs" />
|
||||
<Compile Include="Magick\SceneDetect.cs" />
|
||||
<Compile Include="Main\AutoEncode.cs" />
|
||||
<Compile Include="Main\BatchProcessing.cs" />
|
||||
|
||||
@@ -333,7 +333,7 @@ namespace Flowframes
|
||||
|
||||
private void licenseBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
Process.Start("explorer.exe", Path.Combine(Paths.GetPkgPath(), Path.GetFileNameWithoutExtension(Packages.licenses.fileName)));
|
||||
Process.Start("explorer.exe", Path.Combine(Paths.GetPkgPath(), Paths.licensesDir));
|
||||
}
|
||||
|
||||
private void Form1_DragEnter(object sender, DragEventArgs e) { e.Effect = DragDropEffects.Copy; }
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace Flowframes.IO
|
||||
|
||||
foreach (AI ai in Networks.networks)
|
||||
{
|
||||
string aiPkgFolder = PkgUtils.GetPkgFolder(ai.pkg);
|
||||
string aiPkgFolder = Path.Combine(Paths.GetPkgPath(), ai.pkgDir);
|
||||
string modelsFile = Path.Combine(aiPkgFolder, "models.txt");
|
||||
if (!File.Exists(modelsFile)) continue;
|
||||
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
using Flowframes.Data;
|
||||
using Flowframes.Forms;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Flowframes.IO
|
||||
{
|
||||
class PkgUtils
|
||||
{
|
||||
|
||||
public static string GetPkgFolder (FlowPackage pkg)
|
||||
{
|
||||
return Path.Combine(Paths.GetPkgPath(), Path.GetFileNameWithoutExtension(pkg.fileName));
|
||||
}
|
||||
|
||||
public static bool IsInstalled(FlowPackage pkg)
|
||||
{
|
||||
string path = GetPkgFolder(pkg);
|
||||
return (Directory.Exists(path) && IOUtils.GetAmountOfFiles(path, true) > 0);
|
||||
}
|
||||
|
||||
public static bool IsUpToDate(FlowPackage pkg, int minVersion)
|
||||
{
|
||||
return (GetVersion(pkg) >= minVersion);
|
||||
}
|
||||
|
||||
public static int GetVersion (FlowPackage pkg)
|
||||
{
|
||||
string versionFilePath = Path.Combine(GetPkgFolder(pkg), "ver.ini");
|
||||
if (!File.Exists(versionFilePath))
|
||||
return 0;
|
||||
return IOUtils.ReadLines(versionFilePath)[0].Split('#')[0].GetInt();
|
||||
}
|
||||
|
||||
public static bool IsAiAvailable(AI ai, bool msg = true)
|
||||
{
|
||||
Logger.Log("PkgInstaller.IsAiAvailable - Checking for AI " + ai.aiName, true);
|
||||
return IsInstalled(ai.pkg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ namespace Flowframes.Main
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!PkgUtils.IsAiAvailable(entry.ai))
|
||||
if (IOUtils.GetAmountOfFiles(Path.Combine(Paths.GetPkgPath(), entry.ai.pkgDir), true) < 1)
|
||||
{
|
||||
Logger.Log("[Queue] Can't process queue entry: Selected AI is not available.");
|
||||
return false;
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace Flowframes
|
||||
public static async Task RunAi(string outpath, AI ai, bool stepByStep = false)
|
||||
{
|
||||
Program.mainForm.SetStatus("Downloading models...");
|
||||
await ModelDownloader.DownloadModelFiles(Path.GetFileNameWithoutExtension(ai.pkg.fileName), current.model);
|
||||
await ModelDownloader.DownloadModelFiles(ai.pkgDir, current.model);
|
||||
if (canceled) return;
|
||||
|
||||
currentlyUsingAutoEnc = Utils.CanUseAutoEnc(stepByStep, current);
|
||||
|
||||
@@ -339,7 +339,7 @@ namespace Flowframes.Main
|
||||
|
||||
public static bool CheckAiAvailable(AI ai)
|
||||
{
|
||||
if (!PkgUtils.IsAiAvailable(ai))
|
||||
if (IOUtils.GetAmountOfFiles(Path.Combine(Paths.GetPkgPath(), ai.pkgDir), true) < 1)
|
||||
{
|
||||
ShowMessage("The selected AI is not installed!", "Error");
|
||||
I.Cancel("Selected AI not available.", true);
|
||||
|
||||
@@ -205,7 +205,7 @@ namespace Flowframes
|
||||
|
||||
static string GetAvDir ()
|
||||
{
|
||||
return Path.Combine(Paths.GetPkgPath(), Path.GetFileNameWithoutExtension(Packages.audioVideo.fileName));
|
||||
return Path.Combine(Paths.GetPkgPath(), Paths.audioVideoDir);
|
||||
}
|
||||
|
||||
static string GetCmdArg ()
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace Flowframes
|
||||
|
||||
try
|
||||
{
|
||||
string rifeDir = Path.Combine(Paths.GetPkgPath(), Path.GetFileNameWithoutExtension(Packages.rifeCuda.fileName));
|
||||
string rifeDir = Path.Combine(Paths.GetPkgPath(), Networks.rifeCuda.pkgDir);
|
||||
string script = "rife.py";
|
||||
|
||||
if (!File.Exists(Path.Combine(rifeDir, script)))
|
||||
@@ -151,7 +151,7 @@ namespace Flowframes
|
||||
Process rifePy = OSUtils.NewProcess(!OSUtils.ShowHiddenCmd());
|
||||
AiStarted(rifePy, 3500);
|
||||
SetProgressCheck(Path.Combine(Interpolate.current.tempFolder, outDir), interpFactor);
|
||||
rifePy.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {PkgUtils.GetPkgFolder(Packages.rifeCuda).Wrap()} & " +
|
||||
rifePy.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {Path.Combine(Paths.GetPkgPath(), Networks.rifeCuda.pkgDir).Wrap()} & " +
|
||||
$"set CUDA_VISIBLE_DEVICES={Config.Get("torchGpus")} & {Python.GetPyCmd()} {script} {args}";
|
||||
Logger.Log($"Running RIFE (CUDA){(await InterpolateUtils.UseUHD() ? " (UHD Mode)" : "")}...", false);
|
||||
Logger.Log("cmd.exe " + rifePy.StartInfo.Arguments, true);
|
||||
@@ -240,7 +240,7 @@ namespace Flowframes
|
||||
string oldMdlName = mdl;
|
||||
mdl = RifeNcnn2Workaround(mdl); // TODO: REMOVE ONCE NIHUI HAS GOTTEN RID OF THE SHITTY HARDCODED VERSION CHECK
|
||||
|
||||
rifeNcnn.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {PkgUtils.GetPkgFolder(Packages.rifeNcnn).Wrap()} & rife-ncnn-vulkan.exe " +
|
||||
rifeNcnn.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {Path.Combine(Paths.GetPkgPath(), Networks.rifeNcnn.pkgDir).Wrap()} & rife-ncnn-vulkan.exe " +
|
||||
$" -v -i {inPath.Wrap()} -o {outPath.Wrap()} -m {mdl.ToLower()} {ttaStr} {uhdStr} -g {Config.Get("ncnnGpus")} -f {GetNcnnPattern()} -j {GetNcnnThreads()}";
|
||||
|
||||
Logger.Log("cmd.exe " + rifeNcnn.StartInfo.Arguments, true);
|
||||
@@ -289,7 +289,7 @@ namespace Flowframes
|
||||
|
||||
public static async Task RunDainNcnnProcess (string framesPath, string outPath, float factor, string mdl, int tilesize)
|
||||
{
|
||||
string dainDir = Path.Combine(Paths.GetPkgPath(), Path.GetFileNameWithoutExtension(Packages.dainNcnn.fileName));
|
||||
string dainDir = Path.Combine(Paths.GetPkgPath(), Networks.dainNcnn.pkgDir);
|
||||
Directory.CreateDirectory(outPath);
|
||||
Process dain = OSUtils.NewProcess(!OSUtils.ShowHiddenCmd());
|
||||
AiStarted(dain, 1500);
|
||||
@@ -436,7 +436,7 @@ namespace Flowframes
|
||||
{
|
||||
if (!modelName.StartsWith("RIFE2")) return modelName;
|
||||
string validMdlName = "rife-v2";
|
||||
string rifeFolderPath = Path.Combine(Paths.GetPkgPath(), Path.GetFileNameWithoutExtension(Packages.rifeNcnn.fileName));
|
||||
string rifeFolderPath = Path.Combine(Paths.GetPkgPath(), Networks.rifeNcnn.pkgDir);
|
||||
string modelFolderPath = Path.Combine(rifeFolderPath, modelName);
|
||||
string fixedModelFolderPath = Path.Combine(rifeFolderPath, validMdlName);
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace Flowframes.OS
|
||||
foreach(AI ai in Networks.networks)
|
||||
{
|
||||
var client = new WebClient();
|
||||
string aiName = Path.GetFileNameWithoutExtension(ai.pkg.fileName);
|
||||
string aiName = ai.pkgDir;
|
||||
string url = $"https://raw.githubusercontent.com/n00mkrad/flowframes/main/Pkgs/{aiName}/models.txt";
|
||||
string movePath = Path.Combine(Paths.GetPkgPath(), aiName, "models.txt");
|
||||
string savePath = movePath + ".tmp";
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Flowframes.UI
|
||||
|
||||
try
|
||||
{
|
||||
string pkgPath = PkgUtils.GetPkgFolder(ai.pkg);
|
||||
string pkgPath = Path.Combine(Paths.GetPkgPath(), ai.pkgDir);
|
||||
string modelsFile = Path.Combine(pkgPath, "models.txt");
|
||||
string[] modelsWithDec = IOUtils.ReadLines(modelsFile);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user