This commit is contained in:
Ubuntu
2026-08-06 21:53:22 +08:00
parent 481235c1ee
commit 924bf42a85
2 changed files with 95 additions and 3 deletions
+4 -3
View File
@@ -116,7 +116,7 @@ def _resolve_image_bytes(image_bytes: bytes = None, image_url: str = None) -> by
def _local_face_shape(image_bytes: bytes = None, image_url: str = None) -> str:
"""MediaPipe 脸型分类,返回 display(含混合脸型描述)或主脸型。"""
"""MediaPipe 脸型分类,只返回主脸型(7 类之一),不含混合描述。"""
import cv2
import numpy as np
from face.face_shape_classifier import classify_from_image
@@ -126,11 +126,12 @@ def _local_face_shape(image_bytes: bytes = None, image_url: str = None) -> str:
if bgr is None:
raise ValueError("图片格式不支持,无法解码")
result = classify_from_image(bgr, return_details=True, return_annotated=False)
shape = result.get("display") or result["face_shape"]
shape = result["face_shape"]
logger.info(
"local face_shape=%s conf=%.3f",
"local face_shape=%s conf=%.3f display=%s",
shape,
float(result.get("confidence") or 0),
result.get("display") or shape,
)
return shape