From fe45c459036f88a3f751dbb4047003e61698c8e5 Mon Sep 17 00:00:00 2001 From: Karllas <28707155+Karllas@users.noreply.github.com> Date: Wed, 4 Sep 2024 18:56:05 +0700 Subject: [PATCH 1/2] Update utils.py --- gfpgan/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gfpgan/utils.py b/gfpgan/utils.py index 74ee5a83..405db20a 100644 --- a/gfpgan/utils.py +++ b/gfpgan/utils.py @@ -99,7 +99,7 @@ def __init__(self, model_path, upscale=2, arch='clean', channel_multiplier=2, bg self.gfpgan = self.gfpgan.to(self.device) @torch.no_grad() - def enhance(self, img, has_aligned=False, only_center_face=False, paste_back=True, weight=0.5): + def enhance(self, img, has_aligned=False, only_keep_largest=False, paste_back=True, weight=0.5): self.face_helper.clean_all() if has_aligned: # the inputs are already aligned @@ -108,7 +108,7 @@ def enhance(self, img, has_aligned=False, only_center_face=False, paste_back=Tru else: self.face_helper.read_image(img) # get face landmarks for each face - self.face_helper.get_face_landmarks_5(only_center_face=only_center_face, eye_dist_threshold=5) + self.face_helper.get_face_landmarks_5(only_keep_largest=only_keep_largest, eye_dist_threshold=5) # eye_dist_threshold=5: skip faces whose eye distance is smaller than 5 pixels # TODO: even with eye_dist_threshold, it will still introduce wrong detections and restorations. # align and warp each face From 040b639ef4278c9132be65a38ed4b97508496b01 Mon Sep 17 00:00:00 2001 From: Karllas <28707155+Karllas@users.noreply.github.com> Date: Wed, 18 Sep 2024 18:16:29 +0700 Subject: [PATCH 2/2] Update utils.py --- gfpgan/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfpgan/utils.py b/gfpgan/utils.py index 405db20a..7cd4f7c6 100644 --- a/gfpgan/utils.py +++ b/gfpgan/utils.py @@ -108,7 +108,7 @@ def enhance(self, img, has_aligned=False, only_keep_largest=False, paste_back=Tr else: self.face_helper.read_image(img) # get face landmarks for each face - self.face_helper.get_face_landmarks_5(only_keep_largest=only_keep_largest, eye_dist_threshold=5) + self.face_helper.get_face_landmarks_5(only_keep_largest=only_keep_largest, resize=840, eye_dist_threshold=5) # eye_dist_threshold=5: skip faces whose eye distance is smaller than 5 pixels # TODO: even with eye_dist_threshold, it will still introduce wrong detections and restorations. # align and warp each face