diff --git a/Code/OS/NcnnUtils.cs b/Code/OS/NcnnUtils.cs index a881b39..3c5fbaa 100644 --- a/Code/OS/NcnnUtils.cs +++ b/Code/OS/NcnnUtils.cs @@ -30,6 +30,7 @@ public static async Task ConvertNcnnModel(string modelPath, string filenamePatte { if (IsDirNcnnModel(modelPath)) { + ApplyFilenamePattern(modelPath, filenamePattern); currentNcnnModel = modelPath; return; } @@ -60,9 +61,7 @@ public static async Task ConvertNcnnModel(string modelPath, string filenamePatte Logger.Log("NCNN Model is cached - Skipping conversion."); } - foreach(FileInfo file in IoUtils.GetFileInfosSorted(outPath).Where(f => f.Extension == ".bin" || f.Extension == ".param")) - IoUtils.RenameFile(file.FullName, filenamePattern.Replace("*", $"{file.Name.GetInt()}")); - + ApplyFilenamePattern(outPath, filenamePattern); currentNcnnModel = outPath; } catch (Exception e) @@ -71,6 +70,12 @@ public static async Task ConvertNcnnModel(string modelPath, string filenamePatte } } + static void ApplyFilenamePattern(string path, string pattern) + { + foreach (FileInfo file in IoUtils.GetFileInfosSorted(path).Where(f => f.Extension == ".bin" || f.Extension == ".param")) + IoUtils.RenameFile(file.FullName, pattern.Replace("*", $"{file.Name.GetInt()}")); + } + static async Task RunConverter(string modelPath) { lastNcnnOutput = ""; diff --git a/Code/UI/PreviewUI.cs b/Code/UI/PreviewUI.cs index e55626e..0709b95 100644 --- a/Code/UI/PreviewUI.cs +++ b/Code/UI/PreviewUI.cs @@ -79,7 +79,7 @@ public static async Task UpscaleImage() try { - await Upscale.Run(Paths.imgInPath, Paths.imgOutPath, mdl, false, Config.GetBool("alpha"), PreviewUi.PreviewMode.None); + await Upscale.Run(Paths.imgInPath, Paths.imgOutPath, mdl, false, Config.GetBool("alpha"), PreviewMode.None); if (Program.canceled) return; outImg = Upscale.GetOutputImg(); Program.mainForm.SetProgress(100f, "Post-Processing...");