From 06fa4e58a1172d9b5437755dd73b6d6219c42cb7 Mon Sep 17 00:00:00 2001 From: Wok Date: Thu, 21 Sep 2023 00:15:49 +0200 Subject: [PATCH 1/4] 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 ac45dd43e49b098062a756c60e630ede8bd5e9a5 Mon Sep 17 00:00:00 2001 From: Wok Date: Thu, 21 Sep 2023 11:12:48 +0200 Subject: [PATCH 2/4] 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 8612e012ab071567106e100007a8e595cbfb63c7 Mon Sep 17 00:00:00 2001 From: Wok Date: Thu, 15 Feb 2024 22:01:46 +0100 Subject: [PATCH 3/4] 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 From d76b24569e420354c8e4fec1d4d8644cd05299ec Mon Sep 17 00:00:00 2001 From: Wok Date: Sat, 26 Jul 2025 16:22:01 +0200 Subject: [PATCH 4/4] Fix bug: default value of weights_only changed in PyTorch 2.6 --- models/fs_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/fs_model.py b/models/fs_model.py index 95ac8771..8eb1f3cd 100644 --- a/models/fs_model.py +++ b/models/fs_model.py @@ -61,7 +61,7 @@ def initialize(self, opt): # Id network netArc_checkpoint = opt.Arc_path - netArc_checkpoint = torch.load(netArc_checkpoint, map_location=torch.device("cpu")) + netArc_checkpoint = torch.load(netArc_checkpoint, map_location=torch.device("cpu"), weights_only=False) self.netArc = netArc_checkpoint self.netArc = self.netArc.to(device) self.netArc.eval()