feat: 接口12/接口2 发际线重绘改走 local_test 外部 ComfyUI 服务
后端 generate_hairline_redraw 跳过内置 Flux-2 重绘,改为产出 final(接缝融合基底) + 纯红遮罩 PNG(redraw_band_mask_base64,遮罩区=(255,0,0,255)、其余全透明)。 接口2 female(generate_grow_results_swap) 取 final+遮罩后在后端调 local_test (0716add-hair.json 工作流) 完成重绘,结果作为生发图返回;male 分支不变。 测试页 test_interface12.html / test_interface12_final.html 改为两阶段: 先生成 final+纯红遮罩,再前端调 local_test 重绘并展示;color_match 默认不勾选。 local_test/app.py 加 CORS 头(OPTIONS 预检),支持浏览器跨域直连。
This commit is contained in:
@@ -12,6 +12,27 @@ from PIL import Image, ImageFilter
|
||||
app = Flask(__name__)
|
||||
COMFYUI_URL = "http://127.0.0.1:8188"
|
||||
|
||||
# 允许浏览器跨域直连本服务(如 hair 项目的测试页)。
|
||||
# 不引入 flask-cors 依赖,直接在响应头 + OPTIONS 预检里处理。
|
||||
_CORS_HEADERS = {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
"Access-Control-Allow-Methods": "POST, OPTIONS",
|
||||
"Access-Control-Allow-Headers": "Content-Type",
|
||||
}
|
||||
|
||||
|
||||
@app.after_request
|
||||
def _add_cors(resp):
|
||||
for k, v in _CORS_HEADERS.items():
|
||||
resp.headers[k] = v
|
||||
return resp
|
||||
|
||||
|
||||
@app.route("/api/generate", methods=["OPTIONS"])
|
||||
def _generate_preflight():
|
||||
"""CORS 预检:浏览器 POST 前会先发 OPTIONS。"""
|
||||
return ("", 204)
|
||||
|
||||
|
||||
def build_workflow(image_filename, prompt_text, seed=None):
|
||||
"""Build ComfyUI API workflow from the 0716add-hair.json structure."""
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
* Serving Flask app 'app'
|
||||
* Debug mode: off
|
||||
Address already in use
|
||||
Port 8899 is in use by another program. Either identify and stop that program, or start the server with a different port.
|
||||
+2
-2
@@ -21,12 +21,12 @@ fi
|
||||
# 检查 ComfyUI 是否运行
|
||||
if ! curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8188/ >/dev/null 2>&1; then
|
||||
echo "警告: ComfyUI 未运行 (http://127.0.0.1:8188)"
|
||||
echo "请先启动 ComfyUI: python /home/ubuntu/ComfyUI/main.py --listen"
|
||||
echo "请先启动 ComfyUI: python /home/xsl/ComfyUI/main.py --listen"
|
||||
fi
|
||||
|
||||
# 启动服务
|
||||
echo "启动发型补全服务..."
|
||||
/home/ubuntu/ComfyUI/venv/bin/python app.py >> "$LOG_FILE" 2>&1 &
|
||||
/home/xsl/miniconda3/bin/python app.py >> "$LOG_FILE" 2>&1 &
|
||||
PID=$!
|
||||
echo "$PID" > "$PID_FILE"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user