save code
This commit is contained in:
+22
-8
@@ -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(可以是外部服务或自己的另一个端点)
|
||||
|
||||
+6
-1
@@ -100,6 +100,9 @@
|
||||
<label>
|
||||
<input type="checkbox" id="no2Checkbox"> 设置 no2 不要两步(一步完成)
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" id="tuodiCheckbox"> 设置 tuodi(拖地)
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -145,6 +148,7 @@
|
||||
const humanFile = document.getElementById('humanInput').files[0];
|
||||
const clothFile = document.getElementById('clothInput').files[0];
|
||||
const no2 = document.getElementById("no2Checkbox").checked;
|
||||
const tuodi = document.getElementById("tuodiCheckbox").checked;
|
||||
|
||||
if (!humanFile || !clothFile) {
|
||||
alert('请同时选择人体图片和衣服图片!');
|
||||
@@ -166,12 +170,13 @@
|
||||
cloth_img: clothDataURL, // 包含完整前缀的Base64
|
||||
output_format: "url",
|
||||
no2: no2,
|
||||
tuodi:tuodi
|
||||
};
|
||||
|
||||
console.log("准备发送的数据:", data); // 调试用
|
||||
|
||||
// 调用API
|
||||
fetch('http://112.126.94.241:18888/change_cloth_base64', {
|
||||
fetch('http://112.126.94.241:28888/change_cloth_base64', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
||||
@@ -183,6 +183,7 @@ def call_remote_gpu_server(task_data_str, server=None):
|
||||
"human_url": task_data['request']['human_url'],
|
||||
"cloth_url": task_data['request']["cloth_url"],
|
||||
"no2":task_data['request']['no2'],
|
||||
"tuodi":task_data['request']['tuodi'],
|
||||
"output_format":task_data['request']['output_format']
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user