save code

This commit is contained in:
xsl
2025-08-14 10:45:10 +08:00
parent 261e44eabb
commit f420e8b86c
3 changed files with 29 additions and 9 deletions
+22 -8
View File
@@ -236,7 +236,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):
def change(human_name, cloth_name, c_width, c_height, cloth_url, human_url, no2, tuodi):
human_json_str = GetHumanDesDesc(human_url)
print(f"human_json_str {human_json_str}")
human_json_data = json.loads(human_json_str)
@@ -253,9 +253,12 @@ def change(human_name, cloth_name, c_width, c_height, cloth_url, human_url, no2)
cloth_short = True
if '长袖' in json_data['衣袖']:
cloth_short = False
if cloth_len == '难以辨认':
return None, None, sex_girl, "get image type error"
print(f"GetPicDesc:{json_str}")
print(f"tuodi:{tuodi}")
if tuodi == True or tuodi == "true":
cloth_len = '拖地'
if no2 == True:
print(f'不用第二部 no2{no2}')
else:
@@ -286,7 +289,7 @@ def change(human_name, cloth_name, c_width, c_height, cloth_url, human_url, no2)
if queue["queue_running"] or queue["queue_pending"]:
return None, None, sex_girl, "cur gpu is busy, Shou not happen"
print(f'开始换衣服 {change_only_name}')
print(f'开始换衣服 {change_only_name} cloth_len:{cloth_len} cloth_short:{cloth_short}')
with open(f'{APP_ROOT}/{change_only_name}', 'r', encoding='utf-8') as file:
prompt_text = file.read()
@@ -509,10 +512,10 @@ def upload_to_oss(image_path, object_name=None):
return None
def process_change_cloth(human_filename, cloth_filename, output_format, img_url, human_url, no2):
def process_change_cloth(human_filename, cloth_filename, output_format, img_url, human_url, no2, tuodi):
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)
out_put_name, out_human_name, is_girl, msg = change(human_filename, cloth_filename, w, h, img_url, human_url, no2, tuodi)
if out_put_name == None:
print(f'Failed to change cloth {msg}')
return jsonify({"ret":-1, 'msg': f'Failed to change cloth {msg}'}), 200
@@ -625,8 +628,11 @@ def do_change_cloth():
no2 = data['no2']
check_type(no2)
tuodi = data['tuodi']
print(f"tuodi:{tuodi}")
try:
return process_change_cloth(human_filename, cloth_filename, output_format, cloth_url, human_url, no2)
return process_change_cloth(human_filename, cloth_filename, output_format, cloth_url, human_url, no2, tuodi)
except Exception as e:
traceback.print_exc()
print(f"错误详情:{e}")
@@ -703,6 +709,10 @@ def change_cloth():
if not no2:
data['no2'] = False
tuodi = data.get('tuodi')
if not tuodi:
data['tuodi'] = False
print(f"change_cloth input data:{data}")
return queueCall(data)
@@ -745,6 +755,10 @@ def change_cloth_base64():
if not no2:
data['no2'] = False
tuodi = data.get('tuodi')
if not tuodi:
data['tuodi'] = False
# 在内部调用第二个HTTP请求
try:
# 调用第二个API(可以是外部服务或自己的另一个端点)