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] 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 57e362399..465328ac7 100644 --- a/scripts/postprocessing_gfpgan.py +++ b/scripts/postprocessing_gfpgan.py @@ -26,6 +26,15 @@ class ScriptPostprocessingGfpGan(scripts_postprocessing.ScriptPostprocessing): 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