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 @@ + + +
+ + +正在处理中,请稍候...
+