mirror of
https://github.com/HM-RunningHub/ComfyUI_RH_DreamID-V.git
synced 2026-03-11 15:31:21 +08:00
fix: resolve face detection unpacking error and insightface parameter issue
- Fix FaceLandmarkerResult unpacking error by returning tuple (result, None) when no face is detected in detect() and detect_for_video() methods - Fix insightface FaceAnalysis.get() invalid parameter by setting det_thresh via det_model attribute instead of passing it as argument - Add mesh3d None check to properly trigger insightface fallback detection
This commit is contained in:
@@ -3207,7 +3207,7 @@ class FaceLandmarker(base_vision_task_api.BaseVisionTaskApi):
|
||||
})
|
||||
|
||||
if output_packets[_NORM_LANDMARKS_STREAM_NAME].is_empty():
|
||||
return FaceLandmarkerResult([], [], [])
|
||||
return FaceLandmarkerResult([], [], []), None
|
||||
|
||||
return _build_landmarker_result2(output_packets)
|
||||
|
||||
@@ -3252,7 +3252,7 @@ class FaceLandmarker(base_vision_task_api.BaseVisionTaskApi):
|
||||
})
|
||||
|
||||
if output_packets[_NORM_LANDMARKS_STREAM_NAME].is_empty():
|
||||
return FaceLandmarkerResult([], [], [])
|
||||
return FaceLandmarkerResult([], [], []), None
|
||||
|
||||
return _build_landmarker_result2(output_packets)
|
||||
|
||||
|
||||
@@ -81,8 +81,14 @@ class LMKExtractor():
|
||||
# return None
|
||||
try:
|
||||
detection_result, mesh3d = self.detector.detect(image)
|
||||
# Check if detection failed (mesh3d is None means no face detected)
|
||||
if mesh3d is None:
|
||||
raise Exception("No face detected by mediapipe")
|
||||
except:
|
||||
faces = self.handler.get(frame, det_thresh=det_thresh)
|
||||
# Set detection threshold for insightface
|
||||
if hasattr(self.handler, 'det_model') and self.handler.det_model is not None:
|
||||
self.handler.det_model.det_thresh = det_thresh
|
||||
faces = self.handler.get(frame)
|
||||
if len(faces) < 1:
|
||||
return None
|
||||
h_orig, w_orig = frame.shape[:2]
|
||||
@@ -105,6 +111,9 @@ class LMKExtractor():
|
||||
try:
|
||||
do_insightface = True
|
||||
detection_result, mesh3d = self.detector.detect(mp_image)
|
||||
# Check if detection failed (mesh3d is None means no face detected)
|
||||
if mesh3d is None:
|
||||
raise Exception("No face detected in ROI by mediapipe")
|
||||
# print('face detection success')
|
||||
for landmark in detection_result.face_landmarks[0]:
|
||||
landmark.x = (landmark.x * roi_w + cx1) / w_orig
|
||||
|
||||
Reference in New Issue
Block a user