save code
This commit is contained in:
+15
-8
@@ -12,7 +12,7 @@ from volcenginesdkarkruntime import Ark
|
|||||||
import shutil
|
import shutil
|
||||||
import oss2
|
import oss2
|
||||||
import redis
|
import redis
|
||||||
from check_img_body import is_thigh_visible
|
# from check_img_body import is_thigh_visible
|
||||||
import logging
|
import logging
|
||||||
from config import QUEUE_NAME, DEFAULT_TIMEOUT, KEY_QUEUE_LOCK_NAME, acquire_lock
|
from config import QUEUE_NAME, DEFAULT_TIMEOUT, KEY_QUEUE_LOCK_NAME, acquire_lock
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ def GetHumanDesDesc(img_url):
|
|||||||
"url": img_url
|
"url": img_url
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{"type": "text", "text": "图片是一个人物的照片,返回为json格式, 第一个字段'性别', 判断一下性别,只要答案, 选项有(男、女). 第二个字段'人物',判断一下图片是否有人,只要答案,选项有(有人、没人)"},
|
{"type": "text", "text": "图片是一个人物的照片,返回为json格式, 第一个字段'性别', 判断一下性别,只要答案, 选项有(男、女). 第二个字段'跨',判断一下图片中的人物是否拍摄到了胯的部分,只要答案,选项有(有、没)"},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -122,7 +122,7 @@ def GetHumanDesDesc(img_url):
|
|||||||
print(text)
|
print(text)
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def takeoff_cloth_first(human_name):
|
def takeoff_cloth_first(human_name, is_girl):
|
||||||
print('换泳装')
|
print('换泳装')
|
||||||
queue = requests.get("http://localhost:8188/queue").json()
|
queue = requests.get("http://localhost:8188/queue").json()
|
||||||
if queue["queue_running"] or queue["queue_pending"]:
|
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)
|
# prompt["99"]["inputs"]["width"] = int((c_width/c_height) * 1024)
|
||||||
|
|
||||||
#input cloth img
|
#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
|
#input human img
|
||||||
prompt["61"]["inputs"]["image"] = human_name
|
prompt["61"]["inputs"]["image"] = human_name
|
||||||
@@ -192,9 +195,9 @@ def generate_from_face(human_name, sex_girl):
|
|||||||
prompt["93"]["inputs"]["image"] = human_name
|
prompt["93"]["inputs"]["image"] = human_name
|
||||||
|
|
||||||
if sex_girl:
|
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:
|
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 put name
|
||||||
out_img_name = str(uuid.uuid4())[:8]
|
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:
|
if '男' in sex_type:
|
||||||
sex_girl = False
|
sex_girl = False
|
||||||
|
|
||||||
|
kua = False
|
||||||
|
if human_json_data['跨'] == '有':
|
||||||
|
kua = True
|
||||||
|
|
||||||
|
|
||||||
json_str = GetPicDesc(cloth_url)
|
json_str = GetPicDesc(cloth_url)
|
||||||
json_data = json.loads(json_str)
|
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}')
|
print(f'不用第二部 no2{no2}')
|
||||||
else:
|
else:
|
||||||
print(f'要第二部 no2{no2} 先搞第一步')
|
print(f'要第二部 no2{no2} 先搞第一步')
|
||||||
thigh_visible = is_thigh_visible(f"/home/szlc/code/ComfyUI/input/{human_name}")
|
# thigh_visible = is_thigh_visible(f"/home/szlc/code/ComfyUI/input/{human_name}")
|
||||||
if thigh_visible:
|
if kua:
|
||||||
#脱衣服
|
#脱衣服
|
||||||
takeoff_file_name = takeoff_cloth_first(human_name)
|
takeoff_file_name = takeoff_cloth_first(human_name)
|
||||||
if takeoff_file_name == None:
|
if takeoff_file_name == None:
|
||||||
|
|||||||
+27
-27
@@ -1,39 +1,39 @@
|
|||||||
import cv2
|
import cv2
|
||||||
import mediapipe as mp
|
import mediapipe as mp
|
||||||
|
|
||||||
def is_thigh_visible(image_path):
|
# def is_thigh_visible(image_path):
|
||||||
# 初始化MediaPipe Pose模型
|
# # 初始化MediaPipe Pose模型
|
||||||
mp_pose = mp.solutions.pose
|
# mp_pose = mp.solutions.pose
|
||||||
pose = mp_pose.Pose(static_image_mode=True, min_detection_confidence=0.5)
|
# pose = mp_pose.Pose(static_image_mode=True, min_detection_confidence=0.5)
|
||||||
|
|
||||||
# 读取图像
|
# # 读取图像
|
||||||
image = cv2.imread(image_path)
|
# image = cv2.imread(image_path)
|
||||||
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
# image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
||||||
|
|
||||||
# 进行姿态估计
|
# # 进行姿态估计
|
||||||
results = pose.process(image_rgb)
|
# results = pose.process(image_rgb)
|
||||||
|
|
||||||
if not results.pose_landmarks:
|
# if not results.pose_landmarks:
|
||||||
return False # 未检测到人体
|
# return False # 未检测到人体
|
||||||
|
|
||||||
# 获取关键点
|
# # 获取关键点
|
||||||
landmarks = results.pose_landmarks.landmark
|
# landmarks = results.pose_landmarks.landmark
|
||||||
|
|
||||||
# 检查髋部和膝盖之间的关键点(大腿部分)
|
# # 检查髋部和膝盖之间的关键点(大腿部分)
|
||||||
# MediaPipe关键点索引:
|
# # MediaPipe关键点索引:
|
||||||
# 23: 左髋, 24: 右髋
|
# # 23: 左髋, 24: 右髋
|
||||||
# 25: 左膝, 26: 右膝
|
# # 25: 左膝, 26: 右膝
|
||||||
|
|
||||||
# 检查左大腿是否可见(髋部和膝盖之间)
|
# # 检查左大腿是否可见(髋部和膝盖之间)
|
||||||
left_hip_visible = landmarks[mp_pose.PoseLandmark.LEFT_HIP.value].visibility > 0.6
|
# 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_knee_visible = landmarks[mp_pose.PoseLandmark.LEFT_KNEE.value].visibility > 0.6
|
||||||
left_thigh_visible = left_hip_visible and left_knee_visible
|
# left_thigh_visible = left_hip_visible and left_knee_visible
|
||||||
|
|
||||||
# 检查右大腿是否可见
|
# # 检查右大腿是否可见
|
||||||
right_hip_visible = landmarks[mp_pose.PoseLandmark.RIGHT_HIP.value].visibility > 0.6
|
# 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_knee_visible = landmarks[mp_pose.PoseLandmark.RIGHT_KNEE.value].visibility > 0.6
|
||||||
right_thigh_visible = right_hip_visible and right_knee_visible
|
# 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"))
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 210 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 280 KiB |
Reference in New Issue
Block a user