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 @@