save code
This commit is contained in:
+11
-8
@@ -292,11 +292,11 @@ def change(human_name, cloth_name, c_width, c_height, cloth_url, human_url, no2,
|
||||
return None, None, sex_girl, "cur gpu is busy, Shou not happen"
|
||||
|
||||
if tuodi:
|
||||
print(f'开始换衣服 {change_tuodi_input} cloth_len:{cloth_len} cloth_short:{cloth_short} kuzi:{kuzi}')
|
||||
print(f'开始换衣服 {change_tuodi_input} cloth_len:{cloth_len} cloth_short:{cloth_short}')
|
||||
with open(f'{APP_ROOT}/{change_tuodi_input}', 'r', encoding='utf-8') as file:
|
||||
prompt_text = file.read()
|
||||
else:
|
||||
print(f'开始换衣服 {change_only_name} cloth_len:{cloth_len} cloth_short:{cloth_short} kuzi:{kuzi}')
|
||||
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,7 +509,7 @@ def upload_to_oss(image_path, object_name=None):
|
||||
def process_change_cloth(human_filename, cloth_filename, output_format, img_url, human_url, no2, tuodi, kuzi_url):
|
||||
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, kuzi_url)
|
||||
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
|
||||
@@ -540,8 +540,13 @@ def process_change_cloth(human_filename, cloth_filename, output_format, img_url,
|
||||
|
||||
out_befor_kuzi_url = https_url
|
||||
if kuzi_url:
|
||||
output_path_name = os.path.join(f'{APP_ROOT}/../output', out_put_name)
|
||||
output_path_name_input = os.path.join(f'{APP_ROOT}/../input', out_put_name)
|
||||
shutil.copy(output_path_name, output_path_name_input)
|
||||
|
||||
|
||||
kuzi_filename = save_image_from_url(kuzi_url)
|
||||
kuzi_out_put_name = change_kuzi(human_filename, kuzi_filename)
|
||||
kuzi_out_put_name, msg = change_kuzi(out_put_name, kuzi_filename)
|
||||
image = Image.open(f'{APP_ROOT}/../output/{kuzi_out_put_name}')
|
||||
jpg_name = kuzi_out_put_name.replace(".png", ".jpg")
|
||||
jpg_path_name = f'{APP_ROOT}/static/imgs/{jpg_name}'
|
||||
@@ -558,7 +563,7 @@ def process_change_cloth(human_filename, cloth_filename, output_format, img_url,
|
||||
"ret":0,
|
||||
"state": 0,
|
||||
"msg":"success",
|
||||
"second_step_datea":image_to_base64(out_befor_kuzi_url),
|
||||
"second_step_data":image_to_base64(out_befor_kuzi_url),
|
||||
"first_step_data":image_to_base64(out_human_jpg_path_name),
|
||||
"is_girl":is_girl,
|
||||
"data":image_to_base64(jpg_path_name)
|
||||
@@ -644,12 +649,10 @@ def do_change_cloth():
|
||||
tuodi = data['tuodi']
|
||||
print(f"tuodi:{tuodi}")
|
||||
|
||||
kuzi_url = None
|
||||
if 'kuzi_url' in data:
|
||||
kuzi_url = data.get("kuzi_url")
|
||||
kuzi_filename = save_image_from_url(kuzi_url)
|
||||
print(f"要弄裤子 kuzi:{kuzi_url}")
|
||||
|
||||
|
||||
|
||||
try:
|
||||
return process_change_cloth(human_filename, cloth_filename, output_format, cloth_url, human_url, no2, tuodi, kuzi_url)
|
||||
|
||||
Reference in New Issue
Block a user