diff --git a/scripts/postprocessing_codeformer.py b/scripts/postprocessing_codeformer.py index 53a0cc44cde..7ead73970ce 100644 --- a/scripts/postprocessing_codeformer.py +++ b/scripts/postprocessing_codeformer.py @@ -29,6 +29,10 @@ def process(self, pp: scripts_postprocessing.PostprocessedImage, enable, codefor res = Image.fromarray(restored_img) if codeformer_visibility < 1.0: + if pp.image.size != res.size: + res = res.resize(pp.image.size) + 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 57e3623995c..e39d5eda914 100644 --- a/scripts/postprocessing_gfpgan.py +++ b/scripts/postprocessing_gfpgan.py @@ -26,6 +26,10 @@ def process(self, pp: scripts_postprocessing.PostprocessedImage, enable, gfpgan_ res = Image.fromarray(restored_img) if gfpgan_visibility < 1.0: + if pp.image.size != res.size: + res = res.resize(pp.image.size) + if pp.image.mode != res.mode: + res = res.convert(pp.image.mode) res = Image.blend(pp.image, res, gfpgan_visibility) pp.image = res