diff --git a/Code/OS/ESRGAN.cs b/Code/OS/ESRGAN.cs index fcd3ee5..2f53a39 100644 --- a/Code/OS/ESRGAN.cs +++ b/Code/OS/ESRGAN.cs @@ -31,8 +31,6 @@ public static async Task DoUpscale(string inpath, string outpath, ModelData mdl, { if (backend == Backend.NCNN) { - Program.mainForm.SetProgress(1f, "Loading ESRGAN-NCNN..."); - DialogForm dialogForm = new DialogForm("Loading ESRGAN-NCNN...\nThis should take 10-25 seconds.", 14); Program.lastModelName = mdl.model1Name; await RunNcnn(inpath, outpath, mdl.model1Path); } @@ -319,10 +317,11 @@ public static async Task RunNcnn(string inpath, string outpath, string modelPath inpath = inpath.Wrap(); outpath = outpath.Wrap(); - Program.mainForm.SetProgress(3f, "Converting NCNN model..."); + Program.mainForm.SetProgress(1f, "Converting model..."); await NcnnUtils.ConvertNcnnModel(modelPath); Logger.Log("[ESRGAN] NCNN Model is ready: " + currentNcnnModel); - Program.mainForm.SetProgress(4f, "Loading ESRGAN-NCNN..."); + Program.mainForm.SetProgress(3f, "Loading ESRGAN-NCNN..."); + DialogForm dialog = new DialogForm("Loading ESRGAN-NCNN...\nThis should take 10-25 seconds.", 14); int scale = NcnnUtils.GetNcnnModelScale(currentNcnnModel); string opt = "/C"; diff --git a/Code/OS/NcnnUtils.cs b/Code/OS/NcnnUtils.cs index cad4684..7d0c7ea 100644 --- a/Code/OS/NcnnUtils.cs +++ b/Code/OS/NcnnUtils.cs @@ -1,4 +1,5 @@ -using Cupscale.ImageUtils; +using Cupscale.Forms; +using Cupscale.ImageUtils; using Cupscale.IO; using Cupscale.UI; using System; @@ -26,11 +27,13 @@ public static async Task ConvertNcnnModel(string modelPath) if (IOUtils.GetAmountOfFiles(outPath, false) < 2) { Logger.Log("Running model converter..."); + DialogForm dialog = new DialogForm("Converting ESRGAN model to NCNN format..."); await RunConverter(modelPath); string moveFrom = Path.Combine(Config.Get("esrganPath"), Path.ChangeExtension(modelName, null)); Logger.Log("Moving " + moveFrom + " to " + outPath); IOUtils.Copy(moveFrom, outPath, "*", true); Directory.Delete(moveFrom, true); + dialog.Close(); } else { diff --git a/Code/UI/VideoUpscaleUI.cs b/Code/UI/VideoUpscaleUI.cs index 8b3dbce..017cd71 100644 --- a/Code/UI/VideoUpscaleUI.cs +++ b/Code/UI/VideoUpscaleUI.cs @@ -170,7 +170,16 @@ static void CopyBack (string path) outPath = Path.ChangeExtension(outPath, outputFormat.ToString().ToLower()); Print("Moving output video to " + outPath + "..."); - File.Move(path, outPath); + try + { + if (File.Exists(outPath)) + File.Delete(outPath); + File.Move(path, outPath); + } + catch (Exception e) + { + Logger.ErrorMessage("Failed to move video file to output folder.\nMake sure no other programs are accessing files in that folder.", e); + } } static void RenameOutFiles ()