|
|
|
|
|
def C16(prompt_data, img):
|
|
|
# 图生图
|
|
|
prompt_data["22"]["inputs"]["image"] = img[0]
|
|
|
# 替换关键词
|
|
|
# prompt_data["331"]["inputs"]["text"] = prompt
|
|
|
return prompt_data
|
|
|
|
|
|
|
|
|
def C17(prompt_data, img):
|
|
|
# 上传姿势
|
|
|
# random_number = random.randint(1, 9) # 9张姿势图
|
|
|
# input_image_pose = './Image/C17/' + str(random_number) + '.png'
|
|
|
|
|
|
# 图生图
|
|
|
input_image_pose = './Image/C17/1.jpg'
|
|
|
with open(input_image_pose, "rb") as f:
|
|
|
imgPose = upload_file(server_address, f, "", True)
|
|
|
prompt_data["331"]["inputs"]["image"] = imgPose # 姿势图,现在应该是默认写死在json文件中
|
|
|
|
|
|
prompt_data["432"]["inputs"]["image"] = img[0] # 用户的输入图
|
|
|
|
|
|
# 指定数字长度,例如16位
|
|
|
# number_length = 16
|
|
|
# random_number = generate_random_number(number_length)
|
|
|
# prompt_data["354"]["inputs"]["seed"] = random_number
|
|
|
# random_number = generate_random_number(number_length)
|
|
|
# prompt_data["425"]["inputs"]["seed"] = random_number
|
|
|
# 替换关键词
|
|
|
# prompt_data["331"]["inputs"]["text"] = prompt
|
|
|
|
|
|
return prompt_data
|
|
|
|
|
|
|
|
|
def C19(prompt_data, img):
|
|
|
#
|
|
|
prompt_data["12"]["inputs"]["image"] = img[0]
|
|
|
|
|
|
if len(img) > 1:
|
|
|
prompt_data["27"]["inputs"]["image"] = img[1]
|
|
|
else:
|
|
|
prompt_data["27"]["inputs"]["image"] = img[0]
|
|
|
|
|
|
return prompt_data
|
|
|
|
|
|
|
|
|
def C20(prompt_data, img):
|
|
|
#
|
|
|
prompt_data["12"]["inputs"]["image"] = img[0]
|
|
|
if len(img) > 1:
|
|
|
prompt_data["27"]["inputs"]["image"] = img[1]
|
|
|
else:
|
|
|
input_image_style = './Image/C20/meixi.png' # 只上传一张就与梅西握手
|
|
|
with open(input_image_style, "rb") as f:
|
|
|
image_style = upload_file(server_address, f, "", True)
|
|
|
prompt_data["27"]["inputs"]["image"] = image_style
|
|
|
|
|
|
return prompt_data
|
|
|
|
|
|
|
|
|
def C22(prompt_data, img, model_id):
|
|
|
# TODO 这里的逻辑应该不对了,需要在重复检查22号模型时调整代码
|
|
|
####------------------------------------------------------------####
|
|
|
# 记录下用户的风格图+姿势图的组合,下次生成时,尽时避开已经输出过的组合,让用户更好的玩耍
|
|
|
# 获取目录下有多少个pose,多少个style
|
|
|
directory_path = './Image/C' + str(model_id) + '/'
|
|
|
pose_count = getPrefixFileCount(directory_path, 'pose_')
|
|
|
style_count = getPrefixFileCount(directory_path, 'style_')
|
|
|
style_id = random.randint(1, style_count) # 查找未使用过的姿态图与姿势图,如果找不到就随机用一个
|
|
|
pose_id = random.randint(1, max(pose_count, 1))
|
|
|
# for i in range(1, style_count + 1):
|
|
|
# for j in range(1, pose_count + 1):
|
|
|
# if not checkStylePoseIdExists(user_id, model_id, i, j):
|
|
|
# style_id = i
|
|
|
# pose_id = j
|
|
|
|
|
|
# 回写数据库表,标识这些组合已经用过
|
|
|
# record_style_pose_id(user_id, model_id, style_id, pose_id)
|
|
|
|
|
|
####------------------------------------------------------------####
|
|
|
# 风格图
|
|
|
input_image_style = './Image/C' + str(model_id) + '/style_' + str(style_id) + '.png'
|
|
|
with open(input_image_style, "rb") as f:
|
|
|
image_style = upload_file(server_address, f, "", True)
|
|
|
prompt_data["118"]["inputs"]["image"] = image_style
|
|
|
|
|
|
# 样式图
|
|
|
input_image_pose = './Image/C' + str(model_id) + '/pose_' + str(pose_id) + '.png'
|
|
|
with open(input_image_pose, "rb") as f:
|
|
|
image_pose = upload_file(server_address, f, "", True)
|
|
|
prompt_data["98"]["inputs"]["image"] = image_pose
|
|
|
|
|
|
# 原图
|
|
|
prompt_data["49"]["inputs"]["image"] = img[0]
|
|
|
|
|
|
# 提示词
|
|
|
# prompt_data["131"]["inputs"]["String"] = prompt
|
|
|
|
|
|
return prompt_data
|
|
|
|
|
|
|
|
|
def C23(prompt_data, img):
|
|
|
# 原图
|
|
|
prompt_data["52"]["inputs"]["image"] = img[0]
|
|
|
|
|
|
# prompt_data["331"]["inputs"]["text"] = prompt
|
|
|
|
|
|
return prompt_data
|
|
|
|
|
|
|
|
|
def C24(prompt_data, img):
|
|
|
# 原图
|
|
|
prompt_data["12"]["inputs"]["image"] = img[0]
|
|
|
return prompt_data
|
|
|
|
|
|
|
|
|
"source_images": [
|
|
|
"111,inputs,image"
|
|
|
],
|
|
|
"style_pose_images": [
|
|
|
{
|
|
|
"key": "113,inputs,image",
|
|
|
"value": "./Image/C22/style_1.png"
|
|
|
}
|
|
|
],
|
|
|
|
|
|
def C25(prompt_data, img, model_id):
|
|
|
# 原图
|
|
|
prompt_data["111"]["inputs"]["image"] = img[0]
|
|
|
|
|
|
####------------------------------------------------------------####
|
|
|
# 记录下用户的风格图+姿势图的组合,下次生成时,尽时避开已经输出过的组合,让用户更好的玩耍
|
|
|
# 获取目录下有多少个pose,多少个style
|
|
|
directory_path = './Image/C' + str(model_id) + '/'
|
|
|
pose_count = getPrefixFileCount(directory_path, 'pose_')
|
|
|
style_count = getPrefixFileCount(directory_path, 'style_')
|
|
|
style_id = random.randint(1, style_count) # 查找未使用过的姿态图与姿势图,如果找不到就随机用一个
|
|
|
pose_id = random.randint(1, max(pose_count, 1))
|
|
|
# for i in range(1, style_count + 1):
|
|
|
# for j in range(1, pose_count + 1):
|
|
|
# flag = checkStylePoseIdExists(user_id, model_id, i, j)
|
|
|
# if not flag:
|
|
|
# style_id = i
|
|
|
# pose_id = j
|
|
|
# # 回写数据库表,标识这些组合已经用过
|
|
|
# record_style_pose_id(user_id, model_id, style_id, pose_id)
|
|
|
####------------------------------------------------------------####
|
|
|
|
|
|
with open('./Image/C' + str(model_id) + '/style_' + str(style_id) + ".png", "rb") as f:
|
|
|
y = upload_file(server_address, f, "", True)
|
|
|
|
|
|
# 风格(随机)
|
|
|
prompt_data["113"]["inputs"]["image"] = y
|
|
|
|
|
|
return prompt_data
|
|
|
|
|
|
|
|
|
# 获取C26中有哪些样式
|
|
|
def C26_get_sdxl_styles():
|
|
|
files = ['./JSON/C26/sdxl_styles_sai.json', './JSON/C26/sdxl_styles_twri.json']
|
|
|
SDXL_STYLES = []
|
|
|
for json_file in files:
|
|
|
with open(json_file, 'r', encoding="utf-8") as fi:
|
|
|
data = json.load(fi)
|
|
|
for x in data:
|
|
|
SDXL_STYLES.append(x['name'])
|
|
|
return SDXL_STYLES
|
|
|
|
|
|
|
|
|
def C26(prompt_data, img):
|
|
|
# 原图
|
|
|
prompt_data["13"]["inputs"]["image"] = img[0]
|
|
|
|
|
|
# 风格图片
|
|
|
SDXL_STYLES = C26_get_sdxl_styles()
|
|
|
style_id = random.randint(0, len(SDXL_STYLES) - 1)
|
|
|
pose_id = 1
|
|
|
# for i in range(0, len(SDXL_STYLES)):
|
|
|
# if not checkStylePoseIdExists(user_id, model_id, i, 1):
|
|
|
# style_id = i
|
|
|
#
|
|
|
# # 回写数据库表,标识这些组合已经用过
|
|
|
# record_style_pose_id(user_id, model_id, style_id, pose_id)
|
|
|
|
|
|
prompt_data["79"]["inputs"]["style"] = SDXL_STYLES[style_id]
|
|
|
return prompt_data
|
|
|
|
|
|
|
|
|
def C27(prompt_data, img):
|
|
|
# 原图
|
|
|
if len(img) == 1:
|
|
|
with open('./Image/huanghai_3.png', "rb") as f:
|
|
|
x = upload_file(server_address, f, "", True)
|
|
|
prompt_data["82"]["inputs"]["image"] = x
|
|
|
prompt_data["78"]["inputs"]["image"] = img[0] # 女
|
|
|
else:
|
|
|
prompt_data["13"]["inputs"]["image"] = img[0] # 男
|
|
|
prompt_data["78"]["inputs"]["image"] = img[1] # 女
|
|
|
|
|
|
# 风格图片
|
|
|
style_id = random.randint(1, 2)
|
|
|
pose_id = random.randint(1, 3)
|
|
|
|
|
|
# for i in range(1, 3):
|
|
|
# for j in range(1, 4):
|
|
|
# if not checkStylePoseIdExists(user_id, model_id, i, j):
|
|
|
# style_id = i
|
|
|
# pose_id = j
|
|
|
#
|
|
|
# # 回写数据库表,标识这些组合已经用过
|
|
|
# record_style_pose_id(user_id, model_id, style_id, pose_id)
|
|
|
|
|
|
# 姿势图有3个 pose_id
|
|
|
|
|
|
pose_img_file = './Image/C27/pose_' + str(pose_id) + ".jpg"
|
|
|
# 上传姿势图
|
|
|
with open(pose_img_file, "rb") as f:
|
|
|
y = upload_file(server_address, f, "", True)
|
|
|
prompt_data["82"]["inputs"]["image"] = y
|
|
|
|
|
|
# 模型有2个 style_id
|
|
|
if style_id == 1:
|
|
|
prompt_data["4"]["inputs"]["ckpt_name"] = "samaritan3dCartoon_v40SDXL.safetensors"
|
|
|
else:
|
|
|
prompt_data["4"]["inputs"]["ckpt_name"] = "turbovisionxlSuperFastXLBasedOnNew_tvxlV431Bakedvae.safetensors"
|
|
|
|
|
|
return prompt_data
|