diff --git a/change_app.py b/change_app.py index ff66d49..04810a8 100644 --- a/change_app.py +++ b/change_app.py @@ -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 body,smile,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: diff --git a/check_img_body.py b/check_img_body.py index 7e1a2ce..815c210 100644 --- a/check_img_body.py +++ b/check_img_body.py @@ -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")) \ No newline at end of file +# print(is_thigh_visible("/home/szlc/code/ComfyUI/change_cloth/static/imgs/fc74eded_00001_.jpg")) \ No newline at end of file diff --git a/girl_cloth.jpg b/girl_cloth.jpg new file mode 100644 index 0000000..341b0c2 Binary files /dev/null and b/girl_cloth.jpg differ diff --git a/man_cloth.jpg b/man_cloth.jpg new file mode 100644 index 0000000..ab66807 Binary files /dev/null and b/man_cloth.jpg differ