refactor(接口3): 简化为只需划线图一张,去掉 original + best_hairline
按需求方意见——B端只需上传一张已画好发际线的图,用不着原图: - 入参去掉 original_image_*,只保留 marked_image_*(三选一) - 输出去掉 best_hairline_image_url,只返回 hair_growth_image_url + hairline_type - ComfyUI 输入图改用 marked 划线图原样(add_hair.json 本就是"画了线的照片", 提示词清除黑线);检测路径只用于建遮罩,不再重画干净线/不需对齐原图 - service.generate_grow_b 签名改 (marked_bgr) 单参 - 同步文档:接口文档/接口3技术方案/网关映射表(去掉接口3 best_hairline 行) - 测试更新:grow-b 只传 marked,断言无 best_hairline 字段,44全绿 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+7
-13
@@ -106,33 +106,27 @@ def test_grow_female_returns_5(client, monkeypatch):
|
||||
GROWB = "/api/v1/hair/grow-b"
|
||||
|
||||
|
||||
def test_growb_missing_original_1007(client):
|
||||
files = {"marked_image_file": ("m.jpg", open(fixture("marked_hairline.jpg"), "rb"), "application/octet-stream")}
|
||||
r = client.post(GROWB, headers=H, files=files)
|
||||
def test_growb_missing_marked_1007(client):
|
||||
r = client.post(GROWB, headers=H) # 一张图都没传
|
||||
assert r.json()["code"] == 1007
|
||||
|
||||
|
||||
def test_growb_no_line_1001(client):
|
||||
f = lambda: open(fixture("frontal.jpg"), "rb")
|
||||
files = {"marked_image_file": ("m.jpg", f(), "application/octet-stream"),
|
||||
"original_image_file": ("o.jpg", f(), "application/octet-stream")}
|
||||
r = client.post(GROWB, headers=H, files=files)
|
||||
files = {"marked_image_file": ("m.jpg", open(fixture("frontal.jpg"), "rb"), "application/octet-stream")}
|
||||
r = client.post(GROWB, headers=H, files=files) # 无划线 → 拒识
|
||||
assert r.json()["code"] == 1001
|
||||
|
||||
|
||||
def test_growb_success(client, monkeypatch):
|
||||
import hairline.comfyui as comfy
|
||||
monkeypatch.setattr(comfy, "run", lambda *a, **k: _PNG_1x1)
|
||||
fm = open(fixture("marked_hairline.jpg"), "rb")
|
||||
fo = open(fixture("marked_hairline.jpg"), "rb")
|
||||
files = {"marked_image_file": ("m.jpg", fm, "application/octet-stream"),
|
||||
"original_image_file": ("o.jpg", fo, "application/octet-stream")}
|
||||
body = client.post(GROWB, headers=H, files=files).json()
|
||||
files = {"marked_image_file": ("m.jpg", open(fixture("marked_hairline.jpg"), "rb"), "application/octet-stream")}
|
||||
body = client.post(GROWB, headers=H, files=files).json() # 只传划线图一张
|
||||
assert body["code"] == 0, body
|
||||
d = body["data"]
|
||||
assert d["hairline_type"] == "custom"
|
||||
assert base64.b64decode(d["hair_growth_image_base64"])[:8] == b"\x89PNG\r\n\x1a\n"
|
||||
assert d["best_hairline_image_base64"] # 原图原样(非空)
|
||||
assert "best_hairline_image_base64" not in d # 已去掉该字段
|
||||
assert "best_hairline_image_url" not in d
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user