save code

This commit is contained in:
colomi
2025-07-11 22:57:10 +08:00
parent 4ca55230e8
commit d4a5739887
2 changed files with 236 additions and 3 deletions
+9 -3
View File
@@ -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}'