feat: 拆分接口11/12,新增接口12 final / final v2 精简重绘端点
- 接口11 移除重绘,仅生成 final;接口12 (grow_v2) 负责发际线带 Flux-2 重绘 - 接口12 重绘带改为发际线外推 band_lo_mult~band_hi_mult 倍 push(默认 0.5~1.5),页面可调 - 接口12 同时产出 A 整帧重绘 与 B 局部加发+全脸美颜(beauty_alpha 可调) - 新增 grow_v2_final(整帧重绘)/ grow_v2_final_v2(B 局部+美颜)端点:仅需图片+发型 ID,其余用固化默认值(color_match 关闭) - 配套精简测试页 test_interface12_final.html / test_interface12_final_v2.html / test_interface12.html - 恢复接口11 调试页多频段与换发型可调参数、color_match 默认不勾选 - 删除旧脚本 batch_grow_v2.py / gen_report_hairline_v2.py / test_simple.html Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -55,7 +55,7 @@
|
||||
<h1>接口11 调试页 <span style="font-size:13px;color:#888">(带前后端日志)</span></h1>
|
||||
<div class="subtitle">
|
||||
独立调试页,每一步都记录日志。提交后展开"前端日志"和"后端日志",点按钮可下载。<br>
|
||||
重点排查:遮罩是否走 pushed、①-f/①-g 是否有图、最终遮罩是否正确。遮罩固定 pushed,融合默认 multiband(可调,含两段式)。
|
||||
重点排查:遮罩是否走 pushed、①-f/①-g 是否有图、最终遮罩是否正确。遮罩固定 pushed;默认 blend=two_stage、redraw 开、发际线波浪。
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
@@ -71,48 +71,26 @@
|
||||
<div class="pf">
|
||||
<label>发际线类型 ID</label>
|
||||
<select id="hairlineId">
|
||||
<option value="chang_bolang" selected>chang_bolang(波浪)</option>
|
||||
<option value="chang_zhixian">chang_zhixian(直线)</option>
|
||||
<option value="chang_tuoyuan">chang_tuoyuan(椭圆)</option>
|
||||
<option value="chang_bolang">chang_bolang(波浪)</option>
|
||||
<option value="chang_xinxing">chang_xinxing(心形)</option>
|
||||
<option value="chang_huaban">chang_huaban(花瓣)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="pf">
|
||||
<label>seg_model <span class="desc">分割模型</span></label>
|
||||
<select id="segModel">
|
||||
<option value="segformer">segformer</option>
|
||||
<option value="bisenet">bisenet</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="pf">
|
||||
<label>hairline_push_cm <span class="desc">发际线外推(cm)</span></label>
|
||||
<div class="row"><input type="number" id="hairlinePushCm" min="0" max="3" step="0.1" value="1.0"></div>
|
||||
</div>
|
||||
<div class="pf">
|
||||
<label>hairline_edge <span class="desc">发际线提取</span></label>
|
||||
<select id="hairlineEdge">
|
||||
<option value="column">column(逐列最低点)</option>
|
||||
<option value="contour">contour(形态学轮廓)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="pf">
|
||||
<label>is_hr <span class="desc">高清模式(换发型输出1152×1536)</span></label>
|
||||
<div class="row"><input type="checkbox" id="isHr" style="width:18px;height:18px"><span class="desc">仅 swaphair 后端;关=576×768</span></div>
|
||||
<div class="row"><input type="number" id="hairlinePushCm" min="0" max="3" step="0.1" value="0.8"></div>
|
||||
</div>
|
||||
<div class="pf">
|
||||
<label>mb_levels <span class="desc">多频段金字塔层数</span></label>
|
||||
<div class="row"><input type="number" id="mbLevels" min="2" max="6" step="1" value="5"></div>
|
||||
</div>
|
||||
<div class="pf">
|
||||
<label>edge_erode_px <span class="desc">贴图前遮罩内缩(px)</span></label>
|
||||
<div class="row"><input type="number" id="edgeErodePx" min="0" max="40" step="1" value="3"></div>
|
||||
</div>
|
||||
<div class="pf">
|
||||
<label>blend_method <span class="desc">接缝融合方法</span></label>
|
||||
<select id="blendMethod">
|
||||
<option value="multiband">multiband(多频段金字塔,默认)</option>
|
||||
<option value="two_stage">two_stage(泊松→多频段,大色差)</option>
|
||||
<option value="two_stage" selected>two_stage(泊松→多频段,大色差)</option>
|
||||
<option value="multiband">multiband(多频段金字塔)</option>
|
||||
<option value="seamless">seamless(泊松无缝克隆)</option>
|
||||
<option value="feather">feather(高斯羽化)</option>
|
||||
<option value="alpha_gradient">alpha_gradient(距离变换)</option>
|
||||
@@ -120,26 +98,30 @@
|
||||
</div>
|
||||
<div class="pf">
|
||||
<label>color_match <span class="desc">融合前颜色迁移(消除色差)</span></label>
|
||||
<div class="row"><input type="checkbox" id="colorMatch" checked style="width:18px;height:18px"><span class="desc" id="cmNote">multiband/feather 生效;seamless/two_stage 自带调色</span></div>
|
||||
<div class="row"><input type="checkbox" id="colorMatch" style="width:18px;height:18px"><span class="desc" id="cmNote">multiband/feather 生效;seamless/two_stage 自带调色</span></div>
|
||||
</div>
|
||||
<div class="pf">
|
||||
<label>color_match_strength <span class="desc">颜色迁移强度(0~1)</span></label>
|
||||
<div class="row"><input type="number" id="cmStrength" min="0" max="1" step="0.05" value="1.0"></div>
|
||||
<div class="row"><input type="number" id="cmStrength" min="0" max="1" step="0.05" value="0.4"></div>
|
||||
</div>
|
||||
|
||||
<!-- 多频带融合参数 -->
|
||||
<div class="pf">
|
||||
<label>edge_erode_px <span class="desc">融合·贴图前遮罩内缩(px)</span></label>
|
||||
<div class="row"><input type="number" id="edgeErodePx" min="0" max="40" step="1" value="3"></div>
|
||||
</div>
|
||||
<div class="pf">
|
||||
<label>mb_feather_px <span class="desc">最细层掩码羽化(px)</span></label>
|
||||
<label>mb_feather_px <span class="desc">融合·最细层掩码羽化(px)</span></label>
|
||||
<div class="row"><input type="number" id="mbFeatherPx" min="0" max="5" step="1" value="1"></div>
|
||||
</div>
|
||||
<div class="pf">
|
||||
<label>transition_band_px <span class="desc">过渡带边距(-1=自动)</span></label>
|
||||
<label>transition_band_px <span class="desc">融合·过渡带边距(-1=自动)</span></label>
|
||||
<div class="row"><input type="number" id="transitionBandPx" min="-1" max="128" step="1" value="-1"></div>
|
||||
</div>
|
||||
|
||||
<!-- change_hair 换发型参数 -->
|
||||
<div class="pf">
|
||||
<label>redraw <span class="desc">发际线带重绘开关</span></label>
|
||||
<div class="row"><input type="checkbox" id="redraw" style="width:18px;height:18px"><span class="desc">开:发际线带(外推↔内推)重绘,final输入,swapHair/Flux-2两路对比</span></div>
|
||||
</div>
|
||||
<div class="pf">
|
||||
<label>inpainting_fill <span class="desc">重绘填充(治染绿)</span></label>
|
||||
<label>inpainting_fill <span class="desc">换发型·重绘填充(治染绿)</span></label>
|
||||
<select id="inpaintingFill">
|
||||
<option value="1">1=填充噪声(默认/原始)</option>
|
||||
<option value="0">0=保留原图(治染绿)</option>
|
||||
@@ -148,19 +130,15 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="pf">
|
||||
<label>mask_blur <span class="desc">重绘遮罩边缘模糊(px)</span></label>
|
||||
<label>mask_blur <span class="desc">换发型·重绘遮罩边缘模糊(px)</span></label>
|
||||
<div class="row"><input type="number" id="maskBlur" min="0" max="64" step="1" value="11"></div>
|
||||
</div>
|
||||
<div class="pf">
|
||||
<label>mask_dilate_scale <span class="desc">重绘遮罩膨胀缩放</span></label>
|
||||
<label>mask_dilate_scale <span class="desc">换发型·重绘遮罩膨胀缩放</span></label>
|
||||
<div class="row"><input type="number" id="maskDilateScale" min="0" max="4" step="0.1" value="1.0"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pf" style="margin-top:14px">
|
||||
<label>comfyui_prompt <span class="desc">redraw C路(Flux-2)提示词,留空=默认「补充遮罩区域的头发,加一点美颜」</span></label>
|
||||
<textarea id="comfyuiPrompt" rows="2" style="width:100%;padding:8px;border:1px solid #ddd;border-radius:8px;font-size:13px;font-family:inherit;resize:vertical" placeholder="留空用默认提示词"></textarea>
|
||||
</div>
|
||||
<div style="font-size:12px;color:#888;margin-top:8px">遮罩算法固定 pushed。融合默认 multiband,可在上方 blend_method 切换对比。勾选 redraw 开启发际线带重绘(swapHair/Flux-2 两路对比)。</div>
|
||||
<div style="font-size:12px;color:#888;margin-top:8px">遮罩算法固定 pushed。默认 blend=two_stage;多频带融合参数与 change_hair 换发型参数已在上方可调,其余隐藏参数按原默认值随请求提交。<b>本接口不含重绘</b>,发际线带重绘见 <a href="/static/test_interface12.html">接口12 测试页</a>。</div>
|
||||
</div>
|
||||
|
||||
<div class="status hidden" id="statusBar"></div>
|
||||
@@ -227,9 +205,6 @@ const STEPS = [
|
||||
{ key: 'hard_paste', title: '③ 严格贴回', sub: '遮罩内=生成,外=原图' },
|
||||
{ key: 'alpha', title: '④ 融合权重', sub: '白=用生成图' },
|
||||
{ key: 'final', title: '④ 接缝融合(最终)', sub: '最终输出' },
|
||||
{ key: 'redraw_band_overlay', title: '⑤-① 发际线重绘带', sub: '紫=外推↔内推之间的带(以内轮廓为中心,两侧各push_cm,仅redraw)' },
|
||||
{ key: 'redraw_a', title: '⑤-② 带重绘 swapHair路', sub: 'final+带重绘(swapHair)→final融合(仅redraw)' },
|
||||
{ key: 'redraw_c', title: '⑤-③ 带重绘 Flux-2路', sub: 'final+带重绘(Flux-2,保色不染绿)→final融合(仅redraw)' },
|
||||
];
|
||||
|
||||
function $(id) { return document.getElementById(id); }
|
||||
@@ -255,23 +230,13 @@ function renderResult(d) {
|
||||
$('finalOut').src = pick(s, 'final') || '';
|
||||
$('finalOut').onclick = function(){ zoom(this.src); };
|
||||
const grid = $('stepsGrid'); grid.innerHTML = '';
|
||||
// 固定 pushed:只展示 pushed 相关步骤(不展示 top_fill/closed)
|
||||
// redraw 步骤(redraw_band/redraw_a/redraw_c)只在开启 redraw 且有图时才渲染
|
||||
// 固定 pushed:只展示 pushed 相关步骤(不展示 top_fill/closed;重绘已移到接口12)
|
||||
const showKeys = new Set(['baseline_overlay','upper_overlay','hair_seg_overlay',
|
||||
'hairline_overlay','pushed_overlay','mask_overlay','mask','swap_raw','hard_paste','alpha','final',
|
||||
'redraw_band_overlay','redraw_a','redraw_c']);
|
||||
const redrawKeys = new Set(['redraw_band_overlay','redraw_a','redraw_c']);
|
||||
'hairline_overlay','pushed_overlay','mask_overlay','mask','swap_raw','hard_paste','alpha','final']);
|
||||
$('stepsInfo').textContent = '(mask=pushed, blend=' + (d.blend_method || '?') + ')';
|
||||
if (d.redraw && d.redraw.enabled) {
|
||||
flog('发际线带重绘已开启 band_pixels=' + d.redraw.band_pixels, 'info');
|
||||
} else if (d.redraw && d.redraw.error) {
|
||||
flog('发际线带重绘失败: ' + d.redraw.error, 'warn');
|
||||
}
|
||||
STEPS.filter(st => showKeys.has(st.key)).forEach(st => {
|
||||
const src = pick(s, st.key);
|
||||
const hasImg = src && src.length > 50;
|
||||
// redraw 步骤无图(未开启或失败)时跳过,不占位
|
||||
if (redrawKeys.has(st.key) && !hasImg) return;
|
||||
flog(' 渲染 ' + st.key + ': ' + (hasImg ? '有图(' + src.length + '字符)' : '无图'), hasImg ? 'info' : 'warn');
|
||||
grid.appendChild(stepCard(st.title, st.sub, src));
|
||||
});
|
||||
@@ -281,24 +246,27 @@ function renderResult(d) {
|
||||
async function submitTest() {
|
||||
const file = $('imageFile').files[0];
|
||||
if (!file) { setStatus('请先选择图片', 'error'); return; }
|
||||
// 页面隐藏但仍提交的固定默认值
|
||||
const HIDDEN = {
|
||||
seg_model: 'segformer',
|
||||
hairline_edge: 'column',
|
||||
is_hr: 'false',
|
||||
};
|
||||
|
||||
flog('===== 提交测试 =====', 'info');
|
||||
// 记录前端实际读取的每个参数值(关键诊断)
|
||||
flog('前端读取 hairline_push_cm=' + ($('hairlinePushCm').value || '(默认)'), 'info');
|
||||
flog('前端读取 hairline_edge=' + ($('hairlineEdge').value || '(默认)'), 'info');
|
||||
flog('前端读取 hairline_id=' + $('hairlineId').value, 'info');
|
||||
flog('前端读取 seg_model=' + $('segModel').value, 'info');
|
||||
flog('前端读取 is_hr=' + $('isHr').checked, 'info');
|
||||
flog('前端读取 hairline_push_cm=' + ($('hairlinePushCm').value || '(默认)'), 'info');
|
||||
flog('前端读取 mb_levels=' + ($('mbLevels').value || '(默认)'), 'info');
|
||||
flog('前端读取 blend_method=' + $('blendMethod').value, 'info');
|
||||
flog('前端读取 color_match=' + $('colorMatch').checked, 'info');
|
||||
flog('前端读取 color_match_strength=' + ($('cmStrength').value || '(默认)'), 'info');
|
||||
flog('前端读取 mb_feather_px=' + ($('mbFeatherPx').value || '(默认)'), 'info');
|
||||
flog('前端读取 transition_band_px=' + ($('transitionBandPx').value || '(默认)'), 'info');
|
||||
flog('前端读取 redraw=' + $('redraw').checked, 'info');
|
||||
flog('前端读取 inpainting_fill=' + $('inpaintingFill').value, 'info');
|
||||
flog('前端读取 mask_blur=' + ($('maskBlur').value || '(默认)'), 'info');
|
||||
flog('前端读取 mask_dilate_scale=' + ($('maskDilateScale').value || '(默认)'), 'info');
|
||||
flog('前端读取 comfyui_prompt=' + ($('comfyuiPrompt').value.trim() || '(默认)'), 'info');
|
||||
flog('前端读取 [融合] edge_erode_px=' + ($('edgeErodePx').value || '(默认)')
|
||||
+ ' mb_feather_px=' + ($('mbFeatherPx').value || '(默认)')
|
||||
+ ' transition_band_px=' + ($('transitionBandPx').value || '(默认)'), 'info');
|
||||
flog('前端读取 [换发型] inpainting_fill=' + $('inpaintingFill').value
|
||||
+ ' mask_blur=' + ($('maskBlur').value || '(默认)')
|
||||
+ ' mask_dilate_scale=' + ($('maskDilateScale').value || '(默认)'), 'info');
|
||||
flog('隐藏参数固定: ' + JSON.stringify(HIDDEN), 'info');
|
||||
|
||||
const btn = $('submitBtn');
|
||||
btn.disabled = true; btn.textContent = '⏳ 请求中...';
|
||||
@@ -310,25 +278,22 @@ async function submitTest() {
|
||||
form.append('hairline_id', $('hairlineId').value);
|
||||
form.append('gen_backend', 'swaphair');
|
||||
form.append('hairgrow_strength', '0.75');
|
||||
form.append('is_hr', $('isHr').checked ? 'true' : 'false');
|
||||
form.append('seg_model', $('segModel').value);
|
||||
form.append('is_hr', HIDDEN.is_hr);
|
||||
form.append('seg_model', HIDDEN.seg_model);
|
||||
form.append('swap_mode', 'ext_mask');
|
||||
form.append('edge_erode_px', $('edgeErodePx').value || '3');
|
||||
form.append('denoising_strength', '0.6');
|
||||
form.append('mb_levels', $('mbLevels').value || '5');
|
||||
form.append('hairline_push_cm', $('hairlinePushCm').value || '1.0');
|
||||
form.append('hairline_edge', $('hairlineEdge').value);
|
||||
form.append('hairline_push_cm', $('hairlinePushCm').value || '0.8');
|
||||
form.append('hairline_edge', HIDDEN.hairline_edge);
|
||||
form.append('blend_method', $('blendMethod').value);
|
||||
form.append('color_match', $('colorMatch').checked ? 'true' : 'false');
|
||||
form.append('color_match_strength', $('cmStrength').value || '1.0');
|
||||
form.append('color_match_strength', $('cmStrength').value || '0.4');
|
||||
form.append('mb_feather_px', $('mbFeatherPx').value || '1');
|
||||
form.append('transition_band_px', $('transitionBandPx').value || '-1');
|
||||
form.append('redraw', $('redraw').checked ? 'true' : 'false');
|
||||
form.append('inpainting_fill', $('inpaintingFill').value || '1');
|
||||
form.append('mask_blur', $('maskBlur').value || '11');
|
||||
form.append('mask_dilate_scale', $('maskDilateScale').value || '1.0');
|
||||
const cp = $('comfyuiPrompt').value.trim();
|
||||
if (cp) form.append('comfyui_prompt', cp);
|
||||
|
||||
// 记录发出去的 form 字段
|
||||
const sentFields = {};
|
||||
@@ -402,8 +367,8 @@ async function downloadBackendLog() {
|
||||
// 参数联动(遮罩/融合已固定,无下拉联动)
|
||||
$('imageFile').addEventListener('change', function(){ if(this.files.length) flog('选择图片: ' + this.files[0].name, 'info'); });
|
||||
|
||||
flog('调试页加载完成', 'info');
|
||||
flog('遮罩固定 pushed,融合默认 multiband(可调,含两段式 two_stage),选好图片直接提交', 'info');
|
||||
flog('调试页加载完成(接口11,不含重绘)', 'info');
|
||||
flog('默认: hairline=chang_bolang, push=0.8, blend=two_stage, cm_strength=0.4;多频带融合(edge_erode/mb_feather/transition)与 change_hair 换发型(inpainting_fill/mask_blur/mask_dilate)参数已在页面可调。重绘见接口12 测试页', 'info');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user