Update postprocessing_gfpgan.py

Fix  gfpgan extension , Inconsistent overlay layer types when visibility value is less than 1
This commit is contained in:
klx 2024-12-26 02:16:05 +08:00 committed by GitHub
parent 7953c570d9
commit 6577e063d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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