添加衣服长度字段
This commit is contained in:
+20
-6
@@ -237,7 +237,7 @@ def generate_from_face(human_name, sex_girl):
|
|||||||
return out_img_file_name
|
return out_img_file_name
|
||||||
return None
|
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)
|
human_json_str = GetHumanDesDesc(human_url)
|
||||||
print(f"human_json_str {human_json_str}")
|
print(f"human_json_str {human_json_str}")
|
||||||
human_json_data = json.loads(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['身高完整度']
|
sgwzd = human_json_data['身高完整度']
|
||||||
|
|
||||||
|
cloth_short = True
|
||||||
|
if cloth_len == None:
|
||||||
json_str = GetPicDesc(cloth_url)
|
json_str = GetPicDesc(cloth_url)
|
||||||
|
print(f"GetPicDesc:{json_str}")
|
||||||
json_data = json.loads(json_str)
|
json_data = json.loads(json_str)
|
||||||
cloth_len = json_data['服装长度']
|
cloth_len = json_data['服装长度']
|
||||||
cloth_short = True
|
|
||||||
if '长袖' in json_data['衣袖']:
|
if '长袖' in json_data['衣袖']:
|
||||||
cloth_short = False
|
cloth_short = False
|
||||||
print(f"GetPicDesc:{json_str}")
|
else:
|
||||||
|
print(f'change 函数里面获取的 cloth_len')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print(f"tuodi:{tuodi}")
|
print(f"tuodi:{tuodi}")
|
||||||
|
|
||||||
@@ -603,10 +609,10 @@ def process_change_banana(human_filename, cloth_filename, output_format):
|
|||||||
"msg":"failure"
|
"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}')
|
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:
|
if out_put_name == None:
|
||||||
print(f'Failed to change cloth {msg}')
|
print(f'Failed to change cloth {msg}')
|
||||||
return jsonify({"ret":-1, 'msg': f'Failed to change cloth {msg}'}), 200
|
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")
|
kuzi_url = data.get("kuzi_url")
|
||||||
print(f"要弄裤子 kuzi:{kuzi_url}")
|
print(f"要弄裤子 kuzi:{kuzi_url}")
|
||||||
|
|
||||||
|
cloth_len = None
|
||||||
|
if 'cloth_len' in data:
|
||||||
|
cloth_len = data['cloth_len']
|
||||||
try:
|
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:
|
except Exception as e:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
print(f"错误详情:{e}")
|
print(f"错误详情:{e}")
|
||||||
@@ -902,6 +911,11 @@ def change_cloth_base64():
|
|||||||
if not data.get('suit'):
|
if not data.get('suit'):
|
||||||
data['suit'] = False
|
data['suit'] = False
|
||||||
|
|
||||||
|
if data.get('cloth_len'):
|
||||||
|
print(f'客户端传入了衣服长度: {data['cloth_len']}')
|
||||||
|
else:
|
||||||
|
print('客户端传入了衣服长度,需要ai 判断')
|
||||||
|
|
||||||
|
|
||||||
# 在内部调用第二个HTTP请求
|
# 在内部调用第二个HTTP请求
|
||||||
try:
|
try:
|
||||||
|
|||||||
+47
-7
@@ -79,6 +79,31 @@
|
|||||||
.error {
|
.error {
|
||||||
color: red;
|
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;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -96,13 +121,30 @@
|
|||||||
<input type="file" id="clothInput" accept="image/*">
|
<input type="file" id="clothInput" accept="image/*">
|
||||||
<img id="clothPreview" class="image-preview" alt="衣服图片预览">
|
<img id="clothPreview" class="image-preview" alt="衣服图片预览">
|
||||||
</div>
|
</div>
|
||||||
<br>
|
</div>
|
||||||
|
|
||||||
|
<div class="image-upload-container">
|
||||||
<div class="image-upload-box">
|
<div class="image-upload-box">
|
||||||
<h3>裤子图片</h3>
|
<h3>裤子图片</h3>
|
||||||
<input type="file" id="kuziInput" accept="image/*">
|
<input type="file" id="kuziInput" accept="image/*">
|
||||||
<img id="kuziPreview" class="image-preview" alt="裤子图片预览">
|
<img id="kuziPreview" class="image-preview" alt="裤子图片预览">
|
||||||
</div>
|
</div>
|
||||||
<br>
|
|
||||||
|
<div class="cloth-len-select">
|
||||||
|
<label for="clothLenSelect">选择服装长度:</label>
|
||||||
|
<select id="clothLenSelect">
|
||||||
|
<option value="胸">胸</option>
|
||||||
|
<option value="腰">腰</option>
|
||||||
|
<option value="跨">跨</option>
|
||||||
|
<option value="大腿">大腿</option>
|
||||||
|
<option value="膝盖">膝盖</option>
|
||||||
|
<option value="小腿">小腿</option>
|
||||||
|
<option value="脚踝">脚踝</option>
|
||||||
|
<option value="拖地">拖地</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="option-box">
|
<div class="option-box">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" id="no2Checkbox"> 设置 no2 不要两步(一步完成)
|
<input type="checkbox" id="no2Checkbox"> 设置 no2 不要两步(一步完成)
|
||||||
@@ -115,10 +157,6 @@
|
|||||||
<label>
|
<label>
|
||||||
<input type="checkbox" id="suitCheckbox"> 设置 suit(套装)
|
<input type="checkbox" id="suitCheckbox"> 设置 suit(套装)
|
||||||
</label>
|
</label>
|
||||||
<!-- <label>
|
|
||||||
<input type="checkbox" id="kuziCheckbox"> 设置 kuzi(裤子)
|
|
||||||
</label> -->
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button id="submitBtn">提交处理</button>
|
<button id="submitBtn">提交处理</button>
|
||||||
@@ -179,6 +217,7 @@
|
|||||||
const no2 = document.getElementById("no2Checkbox").checked;
|
const no2 = document.getElementById("no2Checkbox").checked;
|
||||||
const tuodi = document.getElementById("tuodiCheckbox").checked;
|
const tuodi = document.getElementById("tuodiCheckbox").checked;
|
||||||
const suit = document.getElementById("suitCheckbox").checked;
|
const suit = document.getElementById("suitCheckbox").checked;
|
||||||
|
const clothLen = document.getElementById("clothLenSelect").value;
|
||||||
|
|
||||||
|
|
||||||
if (!humanFile || !clothFile) {
|
if (!humanFile || !clothFile) {
|
||||||
@@ -205,7 +244,8 @@
|
|||||||
output_format: "url",
|
output_format: "url",
|
||||||
no2: no2,
|
no2: no2,
|
||||||
tuodi: tuodi,
|
tuodi: tuodi,
|
||||||
suit:suit
|
suit: suit,
|
||||||
|
cloth_len: clothLen // 新增的服装长度字段
|
||||||
};
|
};
|
||||||
|
|
||||||
if(kuziDataURL)
|
if(kuziDataURL)
|
||||||
|
|||||||
Reference in New Issue
Block a user