Files
hair/requirements.txt
T
xslandClaude Opus 4.8 ce95a508c1 feat(接口3): B端生发-马克笔发际线检测+生发(替换Mock)
医生在额头用马克笔画规划发际线 → 检测该线 → 生发。检测算法源自 /home/xsl/headmark。

- hairline/marker_detect.py: 黑帽响应图(MORPH_BLACKHAT)+鬓角锚点(MediaPipe 21/251吸附)
  +skimage route_through_array 最小路径检测画线;路径平均响应阈值拒识无画线
  (headmark 调研:全局灰度阈值不可用,黑帽+Dijkstra 实测误差≤0.5px)
- hairline/mask.py: 抽出 mask_from_curve(曲线+ROI闭合),接口2/3共用
- hairline/service.py: generate_grow_b——检测→遮罩→原图重画干净线→ComfyUI生发
- app.py: /hair/grow-b 真实实现,marked+original各三选一+校验;输出
  best_hairline_image_base64(=原图)/hair_growth_image_base64/hairline_type="custom";
  无人脸或未检测到画线→1001;重活进线程池
- requirements: scikit-image==0.24.0 (⚠️锁0.24,0.25+强依赖numpy>=2会顶掉mediapipe的numpy<2)
- 文档: docs/接口3-B端生发-技术实现方案.md
- 测试: test_marker.py(检测/拒识/辅助) + test_api grow-b(mock ComfyUI),42全绿

实测(5090): grow-b ~6.4s,生发图把额头发际线补到医生画线、清除划线、人物保持。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 00:08:05 +08:00

31 lines
1.6 KiB
Plaintext
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.
fastapi==0.115.12
uvicorn[standard]==0.34.2
python-multipart==0.0.31
httpx==0.28.1
# 接口1:四庭七眼测量(worker 侧算法依赖)
mediapipe==0.10.14 # MediaPipe Face Mesh(经典 Solutions API,模型内置)
opencv-python==4.10.0.84 # 图片读取/处理 + solvePnP 姿态估计
Pillow==11.0.0 # 标注图生成(PNG 透明图层)
numpy==1.26.4 # 必须 <2,否则 mediapipe 0.10.x import 崩溃
# 方案 B:头发分割(BiSeNet face-parsing
# 国内安装可走 Tsinghua 镜像(PyPI 的 linux wheel 即 CUDA 12.1 构建):
# ./venv/bin/pip install torch==2.2.2 torchvision==0.17.2 -i https://pypi.tuna.tsinghua.edu.cn/simple/
# ⚠️ 本 worker 是 RTX 5090sm_120/Blackwell),torch 2.2.2(cu121) 只编到 sm_90
# GPU 上跑算子会报 "no kernel image",代码已自动回退 CPU(方案B 仍可用)。
# 要真正用 5090 GPU,请换 torch cu128(≥2.7+ 对应 torchvision,代码无需改。
torch==2.2.2 # 当前在 5090 上仅 CPU 可用;GPU 需 cu128(≥2.7)
torchvision==0.17.2
# 接口2C端生发(发际线预览)
# MediaPipe Tasks(FaceLandmarker) 用已装的 mediapipe;新增 SegFormer 人脸分割:
transformers==4.45.2 # SegFormer 人脸分割(jonathandinu/face-parsing,本地权重)
# 接口3:B端生发(马克笔发际线检测)
# ⚠️ 必须 0.24.x —— 0.25+ 强依赖 numpy>=2,会顶掉 mediapipe 需要的 numpy<2
scikit-image==0.24.0 # route_through_array(黑帽响应图上的 Dijkstra 最小路径)
# 测试
pytest==8.3.3