Skip to content

Commit

Permalink
Updates Joey's ESRGAN with auto-tiling
Browse files Browse the repository at this point in the history
  • Loading branch information
N00MKRAD committed Dec 16, 2020
1 parent cd9c5a3 commit e261cb2
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Code/Main/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Code/Main/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,8 @@ public void LoadEsrganOptions ()
private void tilesize_SelectedIndexChanged(object sender, EventArgs e)
{
SaveEsrganOptions();
if(initialized && Config.GetInt("esrganVer") == 0)
Program.ShowMessage("Tiling is now automatic when using Joey's ESRGAN. The tile size option will soon be removed.");
}

private void alpha_CheckedChanged(object sender, EventArgs e)
Expand Down
19 changes: 12 additions & 7 deletions Code/OS/ESRGAN.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static async Task DoUpscale(string inpath, string outpath, ModelData mdl,
}
else
{
Program.mainForm.SetProgress(4f, "Starting ESRGAN...");
Program.mainForm.SetProgress(2f, "Starting ESRGAN...");
File.Delete(Paths.progressLogfile);
string modelArg = GetModelArg(mdl, useJoey);
if (useJoey)
Expand Down Expand Up @@ -201,19 +201,19 @@ public static async Task RunJoey(string inpath, string outpath, string modelArg,
string deviceStr = "";
if (Config.Get("cudaFallback").GetInt() == 1 || Config.Get("cudaFallback").GetInt() == 2) deviceStr = "--cpu";

string seamStr = "";
string seamStr = "--seamless ";
switch (Config.Get("seamlessMode").GetInt())
{
case 1: seamStr = "--seamless"; break;
case 2: seamStr = "--mirror"; break;
case 3: seamStr = "--replicate"; break;
case 4: seamStr = "--alpha_padding"; break;
case 1: seamStr += "tile"; break;
case 2: seamStr += "mirror"; break;
case 3: seamStr += "replicate"; break;
case 4: seamStr += "alpha_pad"; break;
}

string opt = stayOpen ? "/K" : "/C";

string cmd = $"{opt} cd /D {Paths.esrganPath.Wrap()} & ";
cmd += $"{EmbeddedPython.GetPyCmd()} upscale.py --input {inpath} --output {outpath} {deviceStr} {seamStr} --tile_size {tilesize} {alphaStr} {modelArg}".TrimWhitespaces();
cmd += $"{EmbeddedPython.GetPyCmd()} upscale.py --input {inpath} --output {outpath} {deviceStr} {seamStr} {alphaStr} {modelArg}".TrimWhitespaces();

Logger.Log("[CMD] " + cmd);
Process esrganProcess = OSUtils.NewProcess(!showWindow);
Expand Down Expand Up @@ -290,6 +290,11 @@ private static async Task UpdateProgressFromFile()
if (outStr == lastProgressString)
return;
lastProgressString = outStr;
if(outStr.Contains("Applying model") || outStr.Contains("Upscaling..."))
{
Program.mainForm.SetProgress(5f, "Upscaling...");
return;
}
string text = outStr.Replace("Tile ", "").Trim();
try
{
Expand Down
1 change: 1 addition & 0 deletions Code/Resources/shipped-files-version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
14 # joey's esrgan update, auto-tiling
13 # new h265 supporting ffmpeg exe
12 # joey's esrgan update, fix chaining
11 # added joey's esrgan to fix seams with esrl code
Expand Down
Binary file modified Installer Files/esrgan.7z
Binary file not shown.
1 change: 1 addition & 0 deletions Installer Files/shipped-files-version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
14 # joey's esrgan update, auto-tiling
13 # new h265 supporting ffmpeg exe
12 # joey's esrgan update, fix chaining
11 # added joey's esrgan to fix seams with esrl code
Expand Down

0 comments on commit e261cb2

Please sign in to comment.