From d4a5739887b524ca7bfb5adc6d0f820027558b86 Mon Sep 17 00:00:00 2001 From: colomi <1421901449@qq.com> Date: Fri, 11 Jul 2025 22:57:10 +0800 Subject: [PATCH] save code --- http_app.py | 12 ++- static/index.html | 227 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 236 insertions(+), 3 deletions(-) create mode 100644 static/index.html diff --git a/http_app.py b/http_app.py index 7b63ed6..9d2666a 100644 --- a/http_app.py +++ b/http_app.py @@ -73,7 +73,7 @@ def GetPicDesc(img_url): return result # ComfyUI 的 input 目录路径(根据实际修改) -COMFYUI_INPUT_DIR = "/path/to/ComfyUI/input" +COMFYUI_INPUT_DIR = "/home/szlc/code/ComfyUI/input" os.makedirs(COMFYUI_INPUT_DIR, exist_ok=True) def get_file_extension(url_or_filename): @@ -148,8 +148,11 @@ def change(human_name, cloth_name, c_width, c_height): print("History:", history) outputs = history[prompt_id]["outputs"] for out in outputs: - if out_img_name in out: - return out + if 'images' in outputs[out]: + for out_img_name in outputs[out]['images']: + if 'filename' in out_img_name: + return out_img_name['filename'] + return None @app.route('/change_cloth', methods=['POST']) def change_cloth(): @@ -279,6 +282,9 @@ def change_cloth_base64(): w,h = get_image_dimensions(f'/home/szlc/code/ComfyUI/input/{human_filename}') out_put_name = change(human_filename, cloth_filename, w, h) + if out_put_name == None: + return jsonify({"ret":-1, 'msg': 'Failed to change cloth'}), 500 + image = Image.open(f'/home/szlc/code/ComfyUI/output/{out_put_name}') jpg_name = out_put_name.replace(".png", ".jpg") jpg_path_name = f'/home/szlc/code/ComfyUI/change_cloth/static/{jpg_name}' diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..d3f133a --- /dev/null +++ b/static/index.html @@ -0,0 +1,227 @@ + + + + + + 服装更换工具 + + + +

服装更换工具

+ +
+
+

人体图片

+ + 人体图片预览 +
+ +
+

衣服图片

+ + 衣服图片预览 +
+
+ + + +
+
+

正在处理中,请稍候...

+
+ +
+ + + + \ No newline at end of file