easydiffusion/installer/patches/gfpgan_custom.patch

23 lines
1.2 KiB
Diff

diff --git a/gfpgan/utils.py b/gfpgan/utils.py
index 74ee5a8..1357f48 100644
--- a/gfpgan/utils.py
+++ b/gfpgan/utils.py
@@ -117,14 +117,14 @@ class GFPGANer():
# face restoration
for cropped_face in self.face_helper.cropped_faces:
# prepare data
- cropped_face_t = img2tensor(cropped_face / 255., bgr2rgb=True, float32=True)
+ cropped_face_t = img2tensor(cropped_face / 255., bgr2rgb=False, float32=True)
normalize(cropped_face_t, (0.5, 0.5, 0.5), (0.5, 0.5, 0.5), inplace=True)
cropped_face_t = cropped_face_t.unsqueeze(0).to(self.device)
try:
- output = self.gfpgan(cropped_face_t, return_rgb=False, weight=weight)[0]
+ output = self.gfpgan(cropped_face_t, return_rgb=True, weight=weight)[0]
# convert to image
- restored_face = tensor2img(output.squeeze(0), rgb2bgr=True, min_max=(-1, 1))
+ restored_face = tensor2img(output.squeeze(0), rgb2bgr=False, min_max=(-1, 1))
except RuntimeError as error:
print(f'\tFailed inference for GFPGAN: {error}.')
restored_face = cropped_face