Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlowFrames 1.41-1.42-1.43 Changelog #275

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Code/Data/InterpSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public InterpSettings (string serializedData)
_inputResolution = new Size(0, 0);
framesExt = "";
interpExt = "";


Dictionary<string, string> entries = new Dictionary<string, string>();

Expand Down Expand Up @@ -215,12 +216,13 @@ public void RefreshExtensions(FrameType type = FrameType.Both)
framesExt = (Config.GetBool(Config.Key.jpegFrames) ? ".jpg" : ".png");

if (type == FrameType.Both || type == FrameType.Interp)
interpExt = (Config.GetBool(Config.Key.jpegInterp) ? ".jpg" : ".png");
interpExt = (Config.GetString(Config.Key.formatofInterp) == "png" ? ".png" : ".jpg");
}

Logger.Log($"RefreshExtensions - Using '{framesExt}' for imported frames, using '{interpExt}' for interpolated frames", true);
}


public string Serialize ()
{
string s = $"INPATH|{inPath}\n";
Expand Down
13 changes: 12 additions & 1 deletion Code/Extensions/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,25 @@ public static float Clamp(this float i, float min, float max)
return i;
}

public static string[] SplitIntoLines(this string str)
/* public static string[] SplitIntoLines(this string str)
{
if (string.IsNullOrWhiteSpace(str))
return new string[0];

return Regex.Split(str, "\r\n|\r|\n");
}*/

public static string[] SplitIntoLines(this string str)
{
if (string.IsNullOrWhiteSpace(str))
return new string[0];

return str.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
}




public static string Trunc(this string inStr, int maxChars, bool addEllipsis = true)
{
string str = inStr.Length <= maxChars ? inStr : inStr.Substring(0, maxChars);
Expand Down
6 changes: 4 additions & 2 deletions Code/Flowframes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>false</Optimize>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
Expand Down Expand Up @@ -422,6 +422,7 @@
<Compile Include="IO\ConfigParser.cs" />
<Compile Include="IO\ModelDownloader.cs" />
<Compile Include="IO\Symlinks.cs" />
<Compile Include="IO\TSource.cs" />
<Compile Include="Magick\Blend.cs" />
<Compile Include="Magick\MagickExtensions.cs" />
<Compile Include="Magick\SceneDetect.cs" />
Expand Down Expand Up @@ -493,6 +494,7 @@
</EmbeddedResource>
<EmbeddedResource Include="Forms\BatchForm.resx">
<DependentUpon>BatchForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\BigPreviewForm.resx">
<DependentUpon>BigPreviewForm.cs</DependentUpon>
Expand Down Expand Up @@ -547,7 +549,7 @@
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 and x64%29</ProductName>
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 und x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
Expand Down
206 changes: 112 additions & 94 deletions Code/Forms/Main/Form1.Designer.cs

Large diffs are not rendered by default.

217 changes: 214 additions & 3 deletions Code/Forms/Main/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
using System.Threading.Tasks;
using System.Linq;
using System.Runtime.InteropServices;
using static WinFormAnimation.AnimationFunctions;
using System.Management;
using System.Threading;
using System.Timers;

#pragma warning disable IDE1006

Expand Down Expand Up @@ -44,8 +48,197 @@ private async void Form1_Load(object sender, EventArgs e)
AutoScaleMode = AutoScaleMode.None;
}

public string ShowTotalPerformance(int sleeptime)
{
const int byteToHigherOrder = 1024 * 1024;
const int byteToHighestOrder = 1024 * 1024 * 1024;
int timeToSleep = sleeptime;

while(true) {

string getCurrentCpuUsage(){
try
{
PerformanceCounter cpuCounter;
cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
cpuCounter.NextValue();
System.Threading.Thread.Sleep(timeToSleep);
return "CPU:" + cpuCounter.NextValue().RoundToInt() + "%";
}

catch (Exception ex) { return "CPU: ERROR"; }
}

string getCurrentRamUsage(){
try{
PerformanceCounter ramCounter;
ramCounter = new PerformanceCounter("Memory", "Available MBytes");
System.Threading.Thread.Sleep(timeToSleep);
float totalram = new Microsoft.VisualBasic.Devices.ComputerInfo().TotalPhysicalMemory;
float totalrambeautiful = (totalram/(byteToHigherOrder));
float availableram = (ramCounter.NextValue());
float usedram = (totalrambeautiful - availableram)/1024;
string usedramtext = String.Format("{0:0.00}", usedram);
float usedrampercent = (usedram / totalrambeautiful)* 1024 * 100;
string beautifulpercent = String.Format("{0:0.00}", usedrampercent);
return "RAM:" + usedramtext + " GB (" + beautifulpercent + "% used RAM)";
}
catch (Exception ex){return "RAM: ERROR";}
}


string GetCudaUsage()
{
try
{
var category = new PerformanceCounterCategory("GPU Engine");
var counterNames = category.GetInstanceNames();
var gpuCounters = new List<PerformanceCounter>();
var result = 0f;

foreach (string counterName in counterNames)
{
if (counterName.EndsWith("engtype_Cuda"))
{
foreach (PerformanceCounter counter in category.GetCounters(counterName))
{
if (counter.CounterName == "Utilization Percentage")
{
gpuCounters.Add(counter);
}
}
}
}

gpuCounters.ForEach(x =>
{
_ = x.NextValue();
});

System.Threading.Thread.Sleep(timeToSleep);

gpuCounters.ForEach(x =>
{
result += x.NextValue();
});
string beautifulpercent = String.Format("{0:0.00}", result);
return "CUDA: " + beautifulpercent + "%";
}
catch
{
return "CUDA: ERROR";
}
}


string GetCudaRamUsage()
{
try
{
var category = new PerformanceCounterCategory("GPU Process Memory");
var counterNames = category.GetInstanceNames();
var gpuCounters = new List<PerformanceCounter>();
var result = 0f;
foreach (string counterName in counterNames) {
if (counterName.EndsWith("phys_0"))
{
foreach (PerformanceCounter counter in category.GetCounters(counterName))
{
if (counter.CounterName == "Dedicated Usage")
{
gpuCounters.Add(counter);
}
}
}
}

gpuCounters.ForEach(x =>
{
_ = x.NextValue();
});

System.Threading.Thread.Sleep(timeToSleep);
gpuCounters.ForEach(x =>
{
result += x.NextValue();
});
string beautifulresult = String.Format("{0:0.00}", (result/(byteToHighestOrder)));
return "GPU RAM: " + beautifulresult + " GB VRAM";
}
catch
{
return "GPU RAM: ERROR";
}
}


string DiskUsageSpeed()
{
try
{
PerformanceCounter avgReadDisk;
PerformanceCounter avgReadWrite;
avgReadDisk = new PerformanceCounter("PhysicalDisk", "Disk Read Bytes/sec", "_Total");
avgReadWrite = new PerformanceCounter("PhysicalDisk", "Disk Write Bytes/sec", "_Total");

avgReadDisk.NextValue();
avgReadWrite.NextValue();
System.Threading.Thread.Sleep(timeToSleep/5);
float speed1 = avgReadDisk.NextValue() + avgReadWrite.NextValue();

avgReadDisk.NextValue();
avgReadWrite.NextValue();
System.Threading.Thread.Sleep(timeToSleep /5);
float speed2 = avgReadDisk.NextValue() + avgReadWrite.NextValue();


avgReadDisk.NextValue();
avgReadWrite.NextValue();
System.Threading.Thread.Sleep(timeToSleep /5);
float speed3 = avgReadDisk.NextValue() + avgReadWrite.NextValue();


avgReadDisk.NextValue();
avgReadWrite.NextValue();
System.Threading.Thread.Sleep(timeToSleep /5);
float speed4 = avgReadDisk.NextValue() + avgReadWrite.NextValue();

int speed5 = ((speed1.RoundToInt() + speed2.RoundToInt() + speed3.RoundToInt() + speed4.RoundToInt()) /4);


string diskreadwrite = "Disk Speed:" + speed5 / byteToHigherOrder + " MB/S";
return diskreadwrite.ToString();
}
catch (Exception ex){ return "Disk Speed: ERROR";}
}



string performancecounter =" Status: " + getCurrentCpuUsage() + " | " + getCurrentRamUsage() + " | " + GetCudaUsage() + " | " + GetCudaRamUsage() + " | " + DiskUsageSpeed();
//Console.WriteLine(performancecounter);
return textBox1.Text = performancecounter ;
}
}



private async Task BackgroundTaskExecuter()
{
await Task.Run(() =>
{
while (true) {
System.Threading.Thread.Sleep(2000);
ShowTotalPerformance(125);
}
});
}


private async void Form1_Shown(object sender, EventArgs e)
{

BackgroundTaskExecuter();

Refresh();
await Task.Delay(1);

Expand Down Expand Up @@ -327,6 +520,8 @@ void InitAis()
aiCombox.Items.Add(GetAiComboboxName(ai));

string lastUsedAiName = Config.Get(Config.Key.lastUsedAiName);

lastUsedAiName = Config.Get(Config.Key.lastUsedAiName);
aiCombox.SelectedIndex = Implementations.NetworksAvailable.IndexOf(Implementations.NetworksAvailable.Where(x => x.NameInternal == lastUsedAiName).FirstOrDefault());
if (aiCombox.SelectedIndex < 0) aiCombox.SelectedIndex = 0;
Config.Set(Config.Key.lastUsedAiName, GetAi().NameInternal);
Expand Down Expand Up @@ -649,7 +844,6 @@ private void previewPicturebox_MouseClick(object sender, MouseEventArgs e)
InterpolationProgress.bigPreviewForm.SetImage(previewPicturebox.Image);
}
}

private async void updateBtn_Click(object sender, EventArgs e)
{
new UpdaterForm().ShowDialog();
Expand Down Expand Up @@ -698,7 +892,6 @@ private void trimCombox_SelectedIndexChanged(object sender, EventArgs e)
trimEndBox.Text = FormatUtils.MsToTimestamp(currInDuration);
}
}

private void trimResetBtn_Click(object sender, EventArgs e)
{
trimCombox_SelectedIndexChanged(null, null);
Expand Down Expand Up @@ -772,7 +965,17 @@ private void fpsOutTbox_Leave(object sender, EventArgs e)
{
float inFps = fpsInTbox.GetFloat();
float outFps = fpsOutTbox.GetFloat();
var targetFactorRounded = Math.Round((Decimal)(outFps / inFps), 3, MidpointRounding.AwayFromZero);
decimal targetFactorRounded = 0;
if (targetFactorRounded == 0)
{
targetFactorRounded = 0;
}

else
{
targetFactorRounded = Math.Round((Decimal)(outFps / inFps), 3, MidpointRounding.AwayFromZero);
}

interpFactorCombox.Text = $"{targetFactorRounded}";
ValidateFactor();
fpsOutTbox.Text = $"{inFps * interpFactorCombox.GetFloat()} FPS";
Expand Down Expand Up @@ -823,5 +1026,13 @@ private void comboxOutputQuality_SelectedIndexChanged(object sender, EventArgs e

Refresh();
}

private void textBox1_TextChanged(object sender, EventArgs e)
{


}


}
}
3 changes: 3 additions & 0 deletions Code/Forms/Main/Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ Based on:
<metadata name="menuStripQueue.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>500, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down
Loading