From 4a0a78e12867fa50347af05633dce2352b771399 Mon Sep 17 00:00:00 2001 From: xsl Date: Sun, 2 Nov 2025 00:12:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A1=A3=E6=9C=8D=E9=95=BF?= =?UTF-8?q?=E5=BA=A6=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- change_app.py | 34 +++++++++++++++++++-------- static/index.html | 58 +++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 73 insertions(+), 19 deletions(-) diff --git a/change_app.py b/change_app.py index 80f1ad6..374839c 100644 --- a/change_app.py +++ b/change_app.py @@ -237,7 +237,7 @@ def generate_from_face(human_name, sex_girl): return out_img_file_name return None -def change(human_name, cloth_name, c_width, c_height, cloth_url, human_url, no2, tuodi): +def change(human_name, cloth_name, c_width, c_height, cloth_url, human_url, no2, tuodi, cloth_len): human_json_str = GetHumanDesDesc(human_url) print(f"human_json_str {human_json_str}") human_json_data = json.loads(human_json_str) @@ -248,13 +248,19 @@ def change(human_name, cloth_name, c_width, c_height, cloth_url, human_url, no2, sgwzd = human_json_data['身高完整度'] - json_str = GetPicDesc(cloth_url) - json_data = json.loads(json_str) - cloth_len = json_data['服装长度'] cloth_short = True - if '长袖' in json_data['衣袖']: - cloth_short = False - print(f"GetPicDesc:{json_str}") + if cloth_len == None: + json_str = GetPicDesc(cloth_url) + print(f"GetPicDesc:{json_str}") + json_data = json.loads(json_str) + cloth_len = json_data['服装长度'] + if '长袖' in json_data['衣袖']: + cloth_short = False + else: + print(f'change 函数里面获取的 cloth_len') + + + print(f"tuodi:{tuodi}") @@ -603,10 +609,10 @@ def process_change_banana(human_filename, cloth_filename, output_format): "msg":"failure" }) -def process_change_cloth(human_filename, cloth_filename, output_format, img_url, human_url, no2, tuodi, kuzi_url): +def process_change_cloth(human_filename, cloth_filename, output_format, img_url, human_url, no2, tuodi, kuzi_url, cloth_len): w,h = get_image_dimensions(f'{APP_ROOT}/../input/{human_filename}') - out_put_name, out_human_name, is_girl, msg = change(human_filename, cloth_filename, w, h, img_url, human_url, no2, tuodi) + out_put_name, out_human_name, is_girl, msg = change(human_filename, cloth_filename, w, h, img_url, human_url, no2, tuodi, cloth_len) if out_put_name == None: print(f'Failed to change cloth {msg}') return jsonify({"ret":-1, 'msg': f'Failed to change cloth {msg}'}), 200 @@ -759,8 +765,11 @@ def do_change_cloth(): kuzi_url = data.get("kuzi_url") print(f"要弄裤子 kuzi:{kuzi_url}") + cloth_len = None + if 'cloth_len' in data: + cloth_len = data['cloth_len'] try: - return process_change_cloth(human_filename, cloth_filename, output_format, cloth_url, human_url, no2, tuodi, kuzi_url) + return process_change_cloth(human_filename, cloth_filename, output_format, cloth_url, human_url, no2, tuodi, kuzi_url, cloth_len) except Exception as e: traceback.print_exc() print(f"错误详情:{e}") @@ -902,6 +911,11 @@ def change_cloth_base64(): if not data.get('suit'): data['suit'] = False + if data.get('cloth_len'): + print(f'客户端传入了衣服长度: {data['cloth_len']}') + else: + print('客户端传入了衣服长度,需要ai 判断') + # 在内部调用第二个HTTP请求 try: diff --git a/static/index.html b/static/index.html index ac0e33b..32fdfed 100644 --- a/static/index.html +++ b/static/index.html @@ -79,6 +79,31 @@ .error { color: red; } + .option-box { + margin: 15px 0; + padding: 15px; + border: 1px solid #ddd; + border-radius: 5px; + } + .option-box label { + display: block; + margin-bottom: 10px; + } + .cloth-len-select { + margin: 15px 0; + } + .cloth-len-select label { + display: block; + margin-bottom: 5px; + font-weight: bold; + } + .cloth-len-select select { + width: 100%; + padding: 8px; + border: 1px solid #ddd; + border-radius: 4px; + font-size: 14px; + } @@ -96,14 +121,31 @@ 衣服图片预览 -
+ + +

裤子图片

裤子图片预览
-
-
+ +
+ + +
+
+ +
@@ -115,10 +157,6 @@ - -
@@ -179,6 +217,7 @@ const no2 = document.getElementById("no2Checkbox").checked; const tuodi = document.getElementById("tuodiCheckbox").checked; const suit = document.getElementById("suitCheckbox").checked; + const clothLen = document.getElementById("clothLenSelect").value; if (!humanFile || !clothFile) { @@ -204,8 +243,9 @@ cloth_img: clothDataURL, // 包含完整前缀的Base64 output_format: "url", no2: no2, - tuodi:tuodi, - suit:suit + tuodi: tuodi, + suit: suit, + cloth_len: clothLen // 新增的服装长度字段 }; if(kuziDataURL)