From 7953c570d9eb7e5da3fcffbfbf244a32b849cf46 Mon Sep 17 00:00:00 2001 From: klx <128426349+Neokmi@users.noreply.github.com> Date: Thu, 26 Dec 2024 02:14:49 +0800 Subject: [PATCH 1/3] Update postprocessing_codeformer.py Fix Codeformer extension , Inconsistent overlay layer types when visibility value is less than 1 --- scripts/postprocessing_codeformer.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/postprocessing_codeformer.py b/scripts/postprocessing_codeformer.py index 53a0cc44cde..9052ed4a11c 100644 --- a/scripts/postprocessing_codeformer.py +++ b/scripts/postprocessing_codeformer.py @@ -29,6 +29,14 @@ def process(self, pp: scripts_postprocessing.PostprocessedImage, enable, codefor res = Image.fromarray(restored_img) if codeformer_visibility < 1.0: + # Ensure consistent size + if pp.image.size != res.size: + res = res.resize(pp.image.size) + + # Ensure consistent mode + if pp.image.mode != res.mode: + res = res.convert(pp.image.mode) + res = Image.blend(pp.image, res, codeformer_visibility) pp.image = res From 6577e063d181b026a33628b085d0a097bba981df Mon Sep 17 00:00:00 2001 From: klx <128426349+Neokmi@users.noreply.github.com> Date: Thu, 26 Dec 2024 02:16:05 +0800 Subject: [PATCH 2/3] Update postprocessing_gfpgan.py Fix gfpgan extension , Inconsistent overlay layer types when visibility value is less than 1 --- scripts/postprocessing_gfpgan.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/postprocessing_gfpgan.py b/scripts/postprocessing_gfpgan.py index 57e3623995c..465328ac7aa 100644 --- a/scripts/postprocessing_gfpgan.py +++ b/scripts/postprocessing_gfpgan.py @@ -26,6 +26,15 @@ def process(self, pp: scripts_postprocessing.PostprocessedImage, enable, gfpgan_ res = Image.fromarray(restored_img) if gfpgan_visibility < 1.0: + + # Ensure consistent size + if pp.image.size != res.size: + res = res.resize(pp.image.size) + + # Ensure consistent mode + if pp.image.mode != res.mode: + res = res.convert(pp.image.mode) + res = Image.blend(pp.image, res, gfpgan_visibility) pp.image = res From f113474a6e2fb8857cb344115840b0bc30166f89 Mon Sep 17 00:00:00 2001 From: w-e-w <40751091+w-e-w@users.noreply.github.com> Date: Thu, 26 Dec 2024 06:26:47 +0900 Subject: [PATCH 3/3] lint --- scripts/postprocessing_codeformer.py | 4 ---- scripts/postprocessing_gfpgan.py | 5 ----- 2 files changed, 9 deletions(-) diff --git a/scripts/postprocessing_codeformer.py b/scripts/postprocessing_codeformer.py index 9052ed4a11c..7ead73970ce 100644 --- a/scripts/postprocessing_codeformer.py +++ b/scripts/postprocessing_codeformer.py @@ -29,14 +29,10 @@ def process(self, pp: scripts_postprocessing.PostprocessedImage, enable, codefor res = Image.fromarray(restored_img) if codeformer_visibility < 1.0: - # Ensure consistent size if pp.image.size != res.size: res = res.resize(pp.image.size) - - # Ensure consistent mode if pp.image.mode != res.mode: res = res.convert(pp.image.mode) - res = Image.blend(pp.image, res, codeformer_visibility) pp.image = res diff --git a/scripts/postprocessing_gfpgan.py b/scripts/postprocessing_gfpgan.py index 465328ac7aa..e39d5eda914 100644 --- a/scripts/postprocessing_gfpgan.py +++ b/scripts/postprocessing_gfpgan.py @@ -26,15 +26,10 @@ def process(self, pp: scripts_postprocessing.PostprocessedImage, enable, gfpgan_ res = Image.fromarray(restored_img) if gfpgan_visibility < 1.0: - - # Ensure consistent size if pp.image.size != res.size: res = res.resize(pp.image.size) - - # Ensure consistent mode if pp.image.mode != res.mode: res = res.convert(pp.image.mode) - res = Image.blend(pp.image, res, gfpgan_visibility) pp.image = res