feat: 新增52号发际线接口并限制GPU worker来源IP
保留5号历史三档实现,新增中下庭高度定位、扶正裁切、矩形叠加与30案例对比页。 worker仅允许本机和配置白名单访问;网关不增加IP限制。空图片URL字段改写限定为52号,保持旧接口兼容。同步接口、裁切与部署文档。 验证:113项测试通过;1项历史数值基线失败,在未修改的a3fddbb版本复现。浏览器验证5/52及30案例对比页通过。
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Straighten the specified reference first, then recalibrate framing ratios."""
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
import cv2
|
||||
from hairline.framing import calibrate_reference, decode_portrait, PROFILE_PATH
|
||||
from hairline.service import get_landmarker
|
||||
|
||||
if __name__ == "__main__":
|
||||
source = Path(sys.argv[1]) if len(sys.argv)>1 else ROOT/"tests/output/upload_framing/reference.jpg"
|
||||
photo = decode_portrait(source.read_bytes())
|
||||
if photo is None:
|
||||
raise ValueError("Reference image cannot be decoded")
|
||||
landmarks = get_landmarker().detect(cv2.cvtColor(photo, cv2.COLOR_BGR2RGB), include_iris=True)
|
||||
if landmarks is None:
|
||||
raise ValueError("Reference face not detected")
|
||||
image, _, profile = calibrate_reference(photo, landmarks)
|
||||
cv2.imwrite(str(ROOT/"static/framing_reference.png"), image)
|
||||
PROFILE_PATH.write_text(json.dumps(profile, ensure_ascii=False, indent=2)+"\n", encoding="utf-8")
|
||||
print(json.dumps(profile, ensure_ascii=False, indent=2))
|
||||
Reference in New Issue
Block a user