Files
hair/scripts/download_weights.sh
T
xslandClaude Opus 4.8 8d3b145111 feat(worker): 接口1 四庭七眼测量真实实现(替换 Mock)
worker 侧从 Mock 替换为真实算法:
- face_analysis 包:detector(MediaPipe 478点) / pose(solvePnP 姿态) /
  calibration(虹膜直径法) / hair_segmenter+bisenet_model(方案B 头发分割) /
  measure(方案A兜底+B/A决策+七眼+换算) / annotation(numpy渐变线+中文标注)
- app.py:/api/v1/face/measure 接真实实现,返回 annotated_image_base64
  (不落盘不拼URL,落盘由网关做);加 X-Internal-Token 鉴权、/health 就绪态、
  可配置分辨率门槛、异常兜底
- 部署:start.sh/run_worker.sh/hair-worker.service 监听 8187;worker_config 示例
- 测试 tests/:Tier1合成真值<1e-6 + Tier2缩放不变 + Tier3叠加 + 错误码集成 +
  数值回归,pytest 24 项全绿
- 文档补实测基线表 + RTX5090/torch 说明

注:worker 为 RTX 5090(sm_120),pinned torch 2.2.2(cu121) 只到 sm_90,
BiSeNet 已自动回退 CPU(方案B 正常);要用 GPU 需换 torch cu128(≥2.7)。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-14 16:07:28 +08:00

40 lines
1.6 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 下载接口1(四庭七眼测量)所需的模型权重与中文字体。
# 内网/离线环境无需执行:文件已随仓库带入(见 OFFLINE_ASSETS.md)。
# 仅供联网环境(生产机重建)使用。
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
WEIGHTS="$ROOT/face_analysis/weights"
FONTS="$ROOT/face_analysis/fonts"
mkdir -p "$WEIGHTS" "$FONTS"
# BiSeNet 主权重(~53MB
if [ ! -f "$WEIGHTS/79999_iter.pth" ]; then
echo ">> 下载 BiSeNet 主权重 79999_iter.pth"
curl -L -o "$WEIGHTS/79999_iter.pth" \
"https://huggingface.co/ManyOtherFunctions/face-parse-bisent/resolve/main/79999_iter.pth"
fi
# BiSeNet 骨干 resnet18~45MB
if [ ! -f "$WEIGHTS/resnet18-5c106cde.pth" ]; then
echo ">> 下载 resnet18 骨干 resnet18-5c106cde.pth"
curl -L -o "$WEIGHTS/resnet18-5c106cde.pth" \
"https://download.pytorch.org/models/resnet18-5c106cde.pth"
fi
# 中文字体(思源黑体,~16MB
if [ ! -f "$FONTS/NotoSansCJKsc-Regular.otf" ]; then
echo ">> 下载中文字体 NotoSansCJKsc-Regular.otf"
curl -L -o "$FONTS/NotoSansCJKsc-Regular.otf" \
"https://github.com/notofonts/noto-cjk/raw/main/Sans/OTF/SimplifiedChinese/NotoSansCJKsc-Regular.otf"
fi
# resnet18 骨干放进 torch 缓存,避免 BiSeNet 初始化联网下载
CACHE="$HOME/.cache/torch/hub/checkpoints"
mkdir -p "$CACHE"
cp -n "$WEIGHTS/resnet18-5c106cde.pth" "$CACHE/" || true
echo ">> 完成。校验 sha256(见 OFFLINE_ASSETS.md):"
sha256sum "$WEIGHTS/79999_iter.pth" "$WEIGHTS/resnet18-5c106cde.pth" "$FONTS/NotoSansCJKsc-Regular.otf"