save code

This commit is contained in:
colomi
2025-07-22 21:47:05 +08:00
parent e53e65b6f4
commit 15a0116f36
4 changed files with 42 additions and 35 deletions
+15 -8
View File
@@ -12,7 +12,7 @@ from volcenginesdkarkruntime import Ark
import shutil
import oss2
import redis
from check_img_body import is_thigh_visible
# from check_img_body import is_thigh_visible
import logging
from config import QUEUE_NAME, DEFAULT_TIMEOUT, KEY_QUEUE_LOCK_NAME, acquire_lock
@@ -111,7 +111,7 @@ def GetHumanDesDesc(img_url):
"url": img_url
},
},
{"type": "text", "text": "图片是一个人物的照片,返回为json格式, 第一个字段'性别', 判断一下性别,只要答案, 选项有(男、女). 第二个字段'人物',判断一下图片是否有人,只要答案,选项有(有、没)"},
{"type": "text", "text": "图片是一个人物的照片,返回为json格式, 第一个字段'性别', 判断一下性别,只要答案, 选项有(男、女). 第二个字段'',判断一下图片中的人物是否拍摄到了胯的部分,只要答案,选项有(有、没)"},
],
}
],
@@ -122,7 +122,7 @@ def GetHumanDesDesc(img_url):
print(text)
return text
def takeoff_cloth_first(human_name):
def takeoff_cloth_first(human_name, is_girl):
print('换泳装')
queue = requests.get("http://localhost:8188/queue").json()
if queue["queue_running"] or queue["queue_pending"]:
@@ -139,7 +139,10 @@ def takeoff_cloth_first(human_name):
# prompt["99"]["inputs"]["width"] = int((c_width/c_height) * 1024)
#input cloth img
prompt["22"]["inputs"]["image"] = 'cloth_black.jpg'
if is_girl:
prompt["22"]["inputs"]["image"] = 'girl_cloth.jpg'
else:
prompt["22"]["inputs"]["image"] = 'man_cloth.jpg'
#input human img
prompt["61"]["inputs"]["image"] = human_name
@@ -192,9 +195,9 @@ def generate_from_face(human_name, sex_girl):
prompt["93"]["inputs"]["image"] = human_name
if sex_girl:
prompt["6"]["inputs"]["text"] = "full body shot(1.9),complete figure,front-facing,model pose, Hands are at the sides of the body, smile,clear skin glow,wearing black micro skirt,simple white background,clean composition,32k,high detail,professional beauty photography style,"
prompt["6"]["inputs"]["text"] = "asian girl,full body shot(1.9),complete figure,front-facing,model pose,hands are at the sides of the body,smile,wearing black tube top and micro skirt,simple ,white background,32k,high detail,and face is illuminated by soft side light and natural light."
else:
prompt["6"]["inputs"]["text"] = "full body shot(1.9),complete figure,front-facing,model pose,Hands are at the sides of the bodysmile,clear skin glow,wearing fitted vest and tight shortst,simple white background,clean composition,32k,high detail,professional beauty photography style,"
prompt["6"]["inputs"]["text"] = "asian man,full body shot(1.9),complete figure,front-facing,model pose,hands are at the sides of the body,smile,wearing black tight shortst,simple white background,32k,high detail,and face is illuminated by soft side light and natural light."
#out put name
out_img_name = str(uuid.uuid4())[:8]
@@ -238,6 +241,10 @@ def change(human_name, cloth_name, c_width, c_height, cloth_url, human_url, no2)
if '' in sex_type:
sex_girl = False
kua = False
if human_json_data[''] == '':
kua = True
json_str = GetPicDesc(cloth_url)
json_data = json.loads(json_str)
@@ -252,8 +259,8 @@ def change(human_name, cloth_name, c_width, c_height, cloth_url, human_url, no2)
print(f'不用第二部 no2{no2}')
else:
print(f'要第二部 no2{no2} 先搞第一步')
thigh_visible = is_thigh_visible(f"/home/szlc/code/ComfyUI/input/{human_name}")
if thigh_visible:
# thigh_visible = is_thigh_visible(f"/home/szlc/code/ComfyUI/input/{human_name}")
if kua:
#脱衣服
takeoff_file_name = takeoff_cloth_first(human_name)
if takeoff_file_name == None:
+27 -27
View File
@@ -1,39 +1,39 @@
import cv2
import mediapipe as mp
def is_thigh_visible(image_path):
# 初始化MediaPipe Pose模型
mp_pose = mp.solutions.pose
pose = mp_pose.Pose(static_image_mode=True, min_detection_confidence=0.5)
# def is_thigh_visible(image_path):
# # 初始化MediaPipe Pose模型
# mp_pose = mp.solutions.pose
# pose = mp_pose.Pose(static_image_mode=True, min_detection_confidence=0.5)
# 读取图像
image = cv2.imread(image_path)
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
# # 读取图像
# image = cv2.imread(image_path)
# image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
# 进行姿态估计
results = pose.process(image_rgb)
# # 进行姿态估计
# results = pose.process(image_rgb)
if not results.pose_landmarks:
return False # 未检测到人体
# if not results.pose_landmarks:
# return False # 未检测到人体
# 获取关键点
landmarks = results.pose_landmarks.landmark
# # 获取关键点
# landmarks = results.pose_landmarks.landmark
# 检查髋部和膝盖之间的关键点(大腿部分)
# MediaPipe关键点索引:
# 23: 左髋, 24: 右髋
# 25: 左膝, 26: 右膝
# # 检查髋部和膝盖之间的关键点(大腿部分)
# # MediaPipe关键点索引:
# # 23: 左髋, 24: 右髋
# # 25: 左膝, 26: 右膝
# 检查左大腿是否可见(髋部和膝盖之间)
left_hip_visible = landmarks[mp_pose.PoseLandmark.LEFT_HIP.value].visibility > 0.6
left_knee_visible = landmarks[mp_pose.PoseLandmark.LEFT_KNEE.value].visibility > 0.6
left_thigh_visible = left_hip_visible and left_knee_visible
# # 检查左大腿是否可见(髋部和膝盖之间)
# left_hip_visible = landmarks[mp_pose.PoseLandmark.LEFT_HIP.value].visibility > 0.6
# left_knee_visible = landmarks[mp_pose.PoseLandmark.LEFT_KNEE.value].visibility > 0.6
# left_thigh_visible = left_hip_visible and left_knee_visible
# 检查右大腿是否可见
right_hip_visible = landmarks[mp_pose.PoseLandmark.RIGHT_HIP.value].visibility > 0.6
right_knee_visible = landmarks[mp_pose.PoseLandmark.RIGHT_KNEE.value].visibility > 0.6
right_thigh_visible = right_hip_visible and right_knee_visible
# # 检查右大腿是否可见
# right_hip_visible = landmarks[mp_pose.PoseLandmark.RIGHT_HIP.value].visibility > 0.6
# right_knee_visible = landmarks[mp_pose.PoseLandmark.RIGHT_KNEE.value].visibility > 0.6
# right_thigh_visible = right_hip_visible and right_knee_visible
return left_thigh_visible and right_thigh_visible
# return left_thigh_visible and right_thigh_visible
print(is_thigh_visible("/home/szlc/code/ComfyUI/change_cloth/static/imgs/fc74eded_00001_.jpg"))
# print(is_thigh_visible("/home/szlc/code/ComfyUI/change_cloth/static/imgs/fc74eded_00001_.jpg"))
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 210 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 280 KiB