You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The link to the face_detector model is broken.
Ideally this should be updated, in the meantime I'd like to share my monkey-patch, where the referenced model can be downloaded at this repo FaceDetection-DSFD
importtorchimportnumpyasnpimporttypingfrom .face_ssdimportSSDfrom .configimportresnet152_model_configfrom ..baseimportDetectorfrom ..buildimportDETECTOR_REGISTRYimportos@DETECTOR_REGISTRY.register_moduleclassDSFDDetector(Detector):
def__init__(
self, *args, **kwargs):
super().__init__(*args, **kwargs)
face_model_path=os.getcwd() +f"/models/WIDERFace_DSFD_RES152.pth"state_dict=torch.load(face_model_path, map_location=torch.device('cpu'))
self.net=SSD(resnet152_model_config)
self.net.load_state_dict(state_dict)
self.net.eval()
self.net=self.net.to(self.device)
@torch.no_grad()def_detect(self, x: torch.Tensor,) ->typing.List[np.ndarray]:
"""Batched detect Args: image (np.ndarray): shape [N, H, W, 3] Returns: boxes: list of length N with shape [num_boxes, 5] per element """# Expects BGRx=x[:, [2, 1, 0], :, :]
withtorch.cuda.amp.autocast(enabled=self.fp16_inference):
boxes=self.net(
x, self.confidence_threshold, self.nms_iou_threshold
)
returnboxes
The text was updated successfully, but these errors were encountered:
The link to the face_detector model is broken.
Ideally this should be updated, in the meantime I'd like to share my monkey-patch, where the referenced model can be downloaded at this repo FaceDetection-DSFD
The text was updated successfully, but these errors were encountered: