Upgrade insightface #447

Open
woctezuma wants to merge 4 commits from woctezuma/upgrade-insightface into main
4 changed files with 6 additions and 8 deletions

View File

@@ -49,7 +49,7 @@ class Face_detect_crop:
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)
@@ -62,7 +62,6 @@ class Face_detect_crop:
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:

View File

@@ -49,7 +49,7 @@ class Face_detect_crop:
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)
@@ -62,7 +62,6 @@ class Face_detect_crop:
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:

View File

@@ -61,7 +61,7 @@ class fsModel(BaseModel):
# 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()

View File

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