添加衣服长度字段

This commit is contained in:
xsl
2025-11-02 00:12:58 +08:00
parent b1a291f6eb
commit 4a0a78e128
2 changed files with 73 additions and 19 deletions
+24 -10
View File
@@ -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: