接口5改造(生发机制与接口2一致,按性别分流): - generate_hairline_pngs: 生发图来源从 _grow_from_texture(局部inpaint) 改为按性别分流——female走 generate_grow_results_swap(swapHair+Flux整帧重绘), male走 generate_grow_results(ComfyUI add_hair) - 新增参数 redraw_max_side/unet_name/v2_defaults(female路径透传) - 接口5 handler 加 flux_model/redraw_max_side Form参数 - 保留接口5独有输出: 3档叠图(middle/high/low)/中心点/face_measure - 已验证: female日志出现"接口2女 管线降分辨率max_side=640"+swap+Flux; male走add_hair.json; generate_grow_image=false正确跳过生发 统一ComfyUI重绘提示词: - "填充遮罩区域的头发,皮肤加一点磨皮,再加一点美颜" → "填充遮罩区域的头发" - 覆盖: _REDRAW_PROMPT/_DEFAULT_PROMPT常量 + app.py各接口Form默认 + 工作流JSON节点60(add_hair/0716add-hair-api/hair_repaint) + 全部测试页输入框
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Test script: send image+mask to the local service and save result."""
|
|
import requests
|
|
import sys
|
|
import os
|
|
|
|
SERVICE_URL = "http://127.0.0.1:8899"
|
|
IMAGE_PATH = "/home/ubuntu/hair/local_test/用来重绘.jpg"
|
|
MASK_PATH = "/home/ubuntu/hair/local_test/用来重绘.png"
|
|
OUTPUT_DIR = "/home/ubuntu/hair/local_test/output"
|
|
|
|
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
|
|
|
print(f"Sending image: {IMAGE_PATH}")
|
|
print(f"Sending mask: {MASK_PATH}")
|
|
|
|
with open(IMAGE_PATH, "rb") as f:
|
|
img_data = f.read()
|
|
with open(MASK_PATH, "rb") as f:
|
|
mask_data = f.read()
|
|
|
|
resp = requests.post(
|
|
f"{SERVICE_URL}/api/generate",
|
|
files={
|
|
"image": ("original.jpg", img_data, "image/jpeg"),
|
|
"mask": ("mask.png", mask_data, "image/png"),
|
|
},
|
|
data={"prompt": "填充遮罩区域的头发"},
|
|
timeout=600,
|
|
)
|
|
|
|
print(f"Status: {resp.status_code}")
|
|
print(f"Content-Type: {resp.headers.get('Content-Type')}")
|
|
|
|
if resp.status_code == 200 and "image" in resp.headers.get("Content-Type", ""):
|
|
out_path = os.path.join(OUTPUT_DIR, "result.png")
|
|
with open(out_path, "wb") as f:
|
|
f.write(resp.content)
|
|
print(f"SUCCESS! Result saved to: {out_path}")
|
|
else:
|
|
print(f"FAILED! Response: {resp.text[:2000]}")
|
|
sys.exit(1)
|