mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-16 16:37:48 +01:00
Dynamically set RIFE NCNN VS GPU threads to reduce VRAM/RAM usage with high resolutions
This commit is contained in:
@@ -338,7 +338,7 @@ namespace Flowframes.Os
|
||||
|
||||
try
|
||||
{
|
||||
Size scaledSize = await InterpolateUtils.GetOutputResolution(Interpolate.currentSettings.inPath, false);
|
||||
Size scaledSize = await InterpolateUtils.GetOutputResolution(Interpolate.currentSettings.inPath, false, false);
|
||||
Logger.Log($"Running RIFE (NCNN-VS){(InterpolateUtils.UseUhd(scaledSize) ? " (UHD Mode)" : "")}...", false);
|
||||
|
||||
await RunRifeNcnnVsProcess(framesPath, factor, outPath, mdl, scaledSize, rt);
|
||||
@@ -384,9 +384,10 @@ namespace Flowframes.Os
|
||||
InterpSettings = Interpolate.currentSettings,
|
||||
ModelDir = mdl,
|
||||
Factor = factor,
|
||||
Res = InterpolateUtils.GetOutputResolution(Interpolate.currentSettings.InputResolution, true, true),
|
||||
Res = res,
|
||||
Uhd = InterpolateUtils.UseUhd(res),
|
||||
GpuId = Config.Get(Config.Key.ncnnGpus).Split(',')[0].GetInt(),
|
||||
GpuThreads = GetRifeNcnnVsGpuThreads(res),
|
||||
SceneDetectSensitivity = Config.GetBool(Config.Key.scnDetect) ? Config.GetFloat(Config.Key.scnDetectValue) * 0.7f : 0f,
|
||||
Loop = Config.GetBool(Config.Key.enableLoop),
|
||||
MatchDuration = Config.GetBool(Config.Key.fixOutputDuration),
|
||||
@@ -648,6 +649,14 @@ namespace Flowframes.Os
|
||||
InterpolationProgress.UpdateLastFrameFromInterpOutput(line);
|
||||
}
|
||||
|
||||
static int GetRifeNcnnVsGpuThreads (Size res)
|
||||
{
|
||||
int threads = 3;
|
||||
if(res.Width * res.Height > 2560 * 1440) threads = 2;
|
||||
if(res.Width * res.Height > 3840 * 2160) threads = 1;
|
||||
return threads;
|
||||
}
|
||||
|
||||
static string GetNcnnPattern()
|
||||
{
|
||||
return $"%0{Padding.interpFrames}d{Interpolate.currentSettings.interpExt}";
|
||||
|
||||
@@ -34,6 +34,9 @@ namespace Flowframes.Os
|
||||
|
||||
public static string CreateScript(VsSettings s)
|
||||
{
|
||||
Logger.Log($"Creating RIFE VS script. Model: {s.ModelDir}, Factor: {s.Factor}, Res: {s.Res.Width}x{s.Res.Height}, UHD: {s.Uhd}, SC Sens: {s.SceneDetectSensitivity}, " +
|
||||
$"GPU ID: {s.GpuId}, GPU Threads: {s.GpuThreads}, TTA: {s.Tta}, Loop: {s.Loop}, Match Duration: {s.MatchDuration}, Dedupe: {s.Dedupe}, RT: {s.Realtime}{(s.Osd ? $", OSD: {s.Osd}" : "")}", true);
|
||||
|
||||
string inputPath = s.InterpSettings.inPath;
|
||||
string mdlPath = Path.Combine(Paths.GetPkgPath(), Implementations.rifeNcnnVs.PkgDir, s.ModelDir).Replace(@"\", "/").Wrap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user