feat(接口2/7): hair_style 支持逗号分隔多选,如 1,2,3
- 参数类型从 int 改为 string(逗号分隔),自动解析去重排序 - 越界/非法值返回 1007 - _parse_hair_styles() 辅助函数:解析 + 去重 + 范围校验 - service 层 hair_style 参数改为 hair_styles: list[int] - 接口2 和 接口7 同步更新 - 服务已重启,smoke test 通过 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+4
-7
@@ -129,11 +129,11 @@ def generate_previews(image_bgr: np.ndarray, gender: str):
|
||||
|
||||
|
||||
def generate_grow_results(image_bgr: np.ndarray, gender: str, use_mask: bool = True,
|
||||
prompt: str = None, hair_style: int = None,
|
||||
prompt: str = None, hair_styles: list[int] | None = None,
|
||||
workflow_path: str | None = None):
|
||||
"""指定发际线类型:预览图(白线) + 生发图(ComfyUI)。
|
||||
|
||||
hair_style(1-indexed):指定生成第几张发际线(按贴图排序)。female: 1..5,male: 1..4。
|
||||
hair_styles(1-indexed 列表):指定生成哪几张发际线(按贴图排序)。female: 1..5,male: 1..4。
|
||||
为 None 时生成全部(兼容旧调用)。
|
||||
use_mask(默认 True):是否启用 inpaint 遮罩,用于测试对比(同接口3)。
|
||||
False 时用**干净原图 + 空遮罩**送 ComfyUI(不烧黑色模板线)。
|
||||
@@ -150,11 +150,8 @@ def generate_grow_results(image_bgr: np.ndarray, gender: str, use_mask: bool = T
|
||||
uv, ext_faces = load_ext_mesh()
|
||||
|
||||
textures = get_texture_map()[gender] # [(key, path), ...] 已排序
|
||||
if hair_style is not None:
|
||||
if hair_style < 1 or hair_style > len(textures):
|
||||
raise ValueError(
|
||||
f"hair_style={hair_style} 超出范围,{gender} 可选 1..{len(textures)}")
|
||||
items = [(hair_style, textures[hair_style - 1])]
|
||||
if hair_styles is not None:
|
||||
items = [(s, textures[s - 1]) for s in hair_styles]
|
||||
else:
|
||||
items = list(enumerate(textures, start=1))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user