Allow fractional factor input (WIP: Disallow for FLAVR/RIFE-CUDA)

This commit is contained in:
n00mkrad
2022-04-05 23:22:09 +02:00
parent 9690101f13
commit 2db247f8ec
4 changed files with 18 additions and 48 deletions

View File

@@ -45,7 +45,7 @@ namespace Flowframes
public InterpSettings() { }
public InterpSettings(string inPathArg, string outPathArg, AI aiArg, Fraction inFpsDetectedArg, Fraction inFpsArg, int interpFactorArg, float itsScale, Interpolate.OutMode outModeArg, ModelCollection.ModelInfo modelArg)
public InterpSettings(string inPathArg, string outPathArg, AI aiArg, Fraction inFpsDetectedArg, Fraction inFpsArg, float interpFactorArg, float itsScale, Interpolate.OutMode outModeArg, ModelCollection.ModelInfo modelArg)
{
inPath = inPathArg;
outPath = outPathArg;

View File

@@ -102,10 +102,11 @@ namespace Flowframes
if (arg.StartsWith("factor="))
{
int factor = arg.Split('=').Last().GetInt();
if (factor == 2) interpFactorCombox.SelectedIndex = 0;
if (factor == 4) interpFactorCombox.SelectedIndex = 1;
if (factor == 8) interpFactorCombox.SelectedIndex = 2;
float factor = arg.Split('=').Last().GetFloat();
interpFactorCombox.Text = factor.ToString();
//if (factor == 2) interpFactorCombox.SelectedIndex = 0;
//if (factor == 4) interpFactorCombox.SelectedIndex = 1;
//if (factor == 8) interpFactorCombox.SelectedIndex = 2;
}
if (arg.StartsWith("ai="))
@@ -165,7 +166,7 @@ namespace Flowframes
{
SetTab("interpolate");
return new InterpSettings(inputTbox.Text.Trim(), outputTbox.Text.Trim(), GetAi(), currInFpsDetected, currInFps,
interpFactorCombox.GetInt(), outSpeedCombox.GetInt().Clamp(1, 64), GetOutMode(), GetModel(GetAi()));
interpFactorCombox.GetFloat(), outSpeedCombox.GetInt().Clamp(1, 64), GetOutMode(), GetModel(GetAi()));
}
public InterpSettings UpdateCurrentSettings(InterpSettings settings)
@@ -183,7 +184,7 @@ namespace Flowframes
settings.ai = GetAi();
settings.inFpsDetected = currInFpsDetected;
settings.inFps = currInFps;
settings.interpFactor = interpFactorCombox.GetInt();
settings.interpFactor = interpFactorCombox.GetFloat();
settings.outFps = settings.inFps * settings.interpFactor;
settings.outMode = GetOutMode();
settings.model = GetModel(GetAi());
@@ -414,17 +415,17 @@ namespace Flowframes
private void interpFactorCombox_SelectedIndexChanged(object sender, EventArgs e)
{
UpdateUiFps();
int guiFactor = interpFactorCombox.GetInt();
if (!initialized)
return;
string aiName = GetAi().aiName.Replace("_", "-");
//int guiFactor = interpFactorCombox.GetInt();
//
//if (!initialized)
// return;
//
//string aiName = GetAi().aiName.Replace("_", "-");
}
public void ValidateFactor()
{
interpFactorCombox.Text = $"x{MainUiFunctions.ValidateInterpFactor(interpFactorCombox.GetInt())}";
interpFactorCombox.Text = $"x{MainUiFunctions.ValidateInterpFactor(interpFactorCombox.GetFloat())}";
}
public void SetWorking(bool state, bool allowCancel = true)

View File

@@ -260,37 +260,6 @@ namespace Flowframes.Os
await AiFinished("RIFE");
}
// static async Task RunRifeNcnnMulti(string framesPath, string outPath, int factor, string mdl)
// {
// int times = (int)Math.Log(factor, 2);
//
// if (times > 1)
// AutoEncode.paused = true; // Disable autoenc until the last iteration
// else
// AutoEncode.paused = false;
//
// for (int iteration = 1; iteration <= times; iteration++)
// {
// if (Interpolate.canceled) return;
//
// if (Interpolate.currentlyUsingAutoEnc && iteration == times) // Enable autoenc if this is the last iteration
// AutoEncode.paused = false;
//
// if (iteration > 1)
// {
// Logger.Log($"Re-Running RIFE for {Math.Pow(2, iteration)}x interpolation...", false);
// string lastInterpPath = outPath + $"-run{iteration - 1}";
// Directory.Move(outPath, lastInterpPath); // Rename last interp folder
// await RunRifeNcnnProcess(lastInterpPath, outPath, mdl);
// await IoUtils.TryDeleteIfExistsAsync(lastInterpPath);
// }
// else
// {
// await RunRifeNcnnProcess(framesPath, outPath, mdl);
// }
// }
// }
static async Task RunRifeNcnnProcess(string inPath, float factor, string outPath, string mdl)
{
Directory.CreateDirectory(outPath);

View File

@@ -153,12 +153,12 @@ namespace Flowframes.Ui
}
}
public static int ValidateInterpFactor (int factor)
public static float ValidateInterpFactor (float factor)
{
AI ai = Program.mainForm.GetAi();
if (factor > 256)
return 256;
if (factor > 256f)
return 256f;
// NO LONGER NEEDED WITH RIFE 3.9
//if (ai.aiName == Implementations.rifeCuda.aiName)