From a76a8eae92fd4b7c2c3421796487465122066e0c Mon Sep 17 00:00:00 2001 From: Wok Date: Thu, 21 Sep 2023 00:15:49 +0200 Subject: [PATCH 1/3] Fix TypeError: RetinaFace.detect() got an unexpected keyword argument 'threshold' --- insightface_func/face_detect_crop_multi.py | 1 - insightface_func/face_detect_crop_single.py | 1 - 2 files changed, 2 deletions(-) diff --git a/insightface_func/face_detect_crop_multi.py b/insightface_func/face_detect_crop_multi.py index d75c36b5..1c5035a8 100644 --- a/insightface_func/face_detect_crop_multi.py +++ b/insightface_func/face_detect_crop_multi.py @@ -62,7 +62,6 @@ def prepare(self, ctx_id, det_thresh=0.5, det_size=(640, 640), mode ='None'): def get(self, img, crop_size, max_num=0): bboxes, kpss = self.det_model.detect(img, - threshold=self.det_thresh, max_num=max_num, metric='default') if bboxes.shape[0] == 0: diff --git a/insightface_func/face_detect_crop_single.py b/insightface_func/face_detect_crop_single.py index f3f648f3..9ab7a9b5 100644 --- a/insightface_func/face_detect_crop_single.py +++ b/insightface_func/face_detect_crop_single.py @@ -62,7 +62,6 @@ def prepare(self, ctx_id, det_thresh=0.5, det_size=(640, 640), mode ='None'): def get(self, img, crop_size, max_num=0): bboxes, kpss = self.det_model.detect(img, - threshold=self.det_thresh, max_num=max_num, metric='default') if bboxes.shape[0] == 0: From 037c7f7a60b747c0b25d7c58e977edd2a8d15276 Mon Sep 17 00:00:00 2001 From: Wok Date: Thu, 21 Sep 2023 11:12:48 +0200 Subject: [PATCH 2/3] Fix bug: set det_thresh inside self.det_model --- insightface_func/face_detect_crop_multi.py | 2 +- insightface_func/face_detect_crop_single.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/insightface_func/face_detect_crop_multi.py b/insightface_func/face_detect_crop_multi.py index 1c5035a8..3b75b9e2 100644 --- a/insightface_func/face_detect_crop_multi.py +++ b/insightface_func/face_detect_crop_multi.py @@ -49,7 +49,7 @@ def __init__(self, name, root='~/.insightface_func/models'): def prepare(self, ctx_id, det_thresh=0.5, det_size=(640, 640), mode ='None'): - self.det_thresh = det_thresh + self.det_model.det_thresh = det_thresh self.mode = mode assert det_size is not None print('set det-size:', det_size) diff --git a/insightface_func/face_detect_crop_single.py b/insightface_func/face_detect_crop_single.py index 9ab7a9b5..9061d470 100644 --- a/insightface_func/face_detect_crop_single.py +++ b/insightface_func/face_detect_crop_single.py @@ -49,7 +49,7 @@ def __init__(self, name, root='~/.insightface_func/models'): def prepare(self, ctx_id, det_thresh=0.5, det_size=(640, 640), mode ='None'): - self.det_thresh = det_thresh + self.det_model.det_thresh = det_thresh self.mode = mode assert det_size is not None print('set det-size:', det_size) From febc35aee877b2badc15ea2690c20f78ef16a890 Mon Sep 17 00:00:00 2001 From: Wok Date: Thu, 15 Feb 2024 22:01:46 +0100 Subject: [PATCH 3/3] Fix AttributeError: module 'numpy' has no attribute 'float' --- util/reverse2original.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/reverse2original.py b/util/reverse2original.py index 83f1bdb8..fb7b1937 100644 --- a/util/reverse2original.py +++ b/util/reverse2original.py @@ -154,9 +154,9 @@ def reverse2wholeimage(b_align_crop_tenor_list,swaped_imgs, mats, crop_size, ori # target_image_parsing = postprocess(target_image, source_image, tgt_mask) if use_mask: - target_image = np.array(target_image, dtype=np.float) * 255 + target_image = np.array(target_image, dtype=np.float32) * 255 else: - target_image = np.array(target_image, dtype=np.float)[..., ::-1] * 255 + target_image = np.array(target_image, dtype=np.float32)[..., ::-1] * 255 img_mask_list.append(img_mask) @@ -165,7 +165,7 @@ def reverse2wholeimage(b_align_crop_tenor_list,swaped_imgs, mats, crop_size, ori # target_image /= 255 # target_image = 0 - img = np.array(oriimg, dtype=np.float) + img = np.array(oriimg, dtype=np.float32) for img_mask, target_image in zip(img_mask_list, target_image_list): img = img_mask * target_image + (1-img_mask) * img