main
黄海 1 year ago
parent 1d56c920ab
commit 3bc5ab0c32

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

@ -1,61 +0,0 @@
{
"model_name": "古风汉服",
"memo": "【半身】",
"pose_image": "./Image/model_10_controllnet.png",
"denoising_strength": 0,
"prompts": [
"(photorealistic, best quality, ultra high res, extremely detailed eyes and face:1.3),(1girl, solo:1.3),skirt,jewelry,long_hair,necklace,earrings,perfect body,standing,large breasts,looking at viewer,chinese clothes,china dress,hanfu,"
],
"negative_prompt": "NSFW,blurry,low quality,watermark,monochrome,badhandv4,easynegative,ng_deepnegative_v1_75t,bad proportions,mutated hands and fingers,poorly drawn face,extra limb,missing limb,malformed limbs,disconnected limbs,ugly,floating limbs,extra legs,mutation,bad body,long neck,cross-eyed,text,Multiple people,cleavage,",
"seed": -1,
"sampler_name": "DPM++ 2M Karras",
"cfg_scale": 7,
"width": 1024,
"height": 1368,
"batch_size": 1,
"n_iter": 1,
"steps": 30,
"return_grid": true,
"send_images": true,
"save_images": false,
"do_not_save_samples": false,
"do_not_save_grid": false,
"override_settings": {
"sd_model_checkpoint": "SDXL古风汉服MAX_v1.0.safetensors [ba140e252c]",
"sd_vae": "Automatic"
},
"alwayson_scripts": {
"ControlNet": {
"args": [
{
"enabled": true,
"model": "ip-adapter_instant_id_sdxl [eb2d3ec0]",
"module": "instant_id_face_embedding",
"weight": 1,
"resize_mode": "Crop and Resize",
"guidance_start": 0,
"guidance_end": 1,
"pixel_perfect": true,
"processor_res": 512,
"save_detected_map": false,
"input_image": "{{input_image1}}",
"control_mode": "Balanced"
},
{
"enabled": true,
"model": "control_instant_id_sdxl [c5c25a50]",
"module": "instant_id_face_keypoints",
"weight": 0.65,
"resize_mode": "Crop and Resize",
"guidance_start": 0,
"guidance_end": 1,
"pixel_perfect": true,
"processor_res": 512,
"save_detected_map": false,
"input_image": "{{input_image2}}",
"control_mode": "ControlNet is more important"
}
]
}
}
}

@ -0,0 +1,57 @@
{
"override_settings": {
"sd_model_checkpoint": "SDXL古风汉服MAX_v1.0.safetensors [ba140e252c]",
"sd_vae": "Automatic"
},
"prompt": "(photorealistic, best quality, ultra high res, extremely detailed eyes and face:1.3),(1girl, solo:1.3),skirt,jewelry,long_hair,necklace,earrings,perfect body,standing,large breasts,looking at viewer,chinese clothes,china dress,hanfu,",
"negative_prompt": "NSFW,blurry,low quality,watermark,monochrome,badhandv4,easynegative,ng_deepnegative_v1_75t,bad proportions,mutated hands and fingers,poorly drawn face,extra limb,missing limb,malformed limbs,disconnected limbs,ugly,floating limbs,extra legs,mutation,bad body,long neck,cross-eyed,text,cleavage,",
"steps": 25,
"sampler_name": "DPM++ 2M Karras",
"width": 1024,
"height": 1472,
"batch_size": 1,
"n_iter": 1,
"seed": 1,
"cfg_scale": 7,
"CLIP_stop_at_last_layers": 2,
"init_images": [
"string"
],
"restore_faces": false,
"enable_hr": true,
"denoising_strength": 0.5,
"alwayson_scripts": {
"ControlNet": {
"args": [
{
"enabled": true,
"model": "ip-adapter_instant_id_sdxl [eb2d3ec0]",
"module": "instant_id_face_embedding",
"weight": 1,
"resize_mode": "Crop and Resize",
"guidance_start": 0,
"guidance_end": 1,
"pixel_perfect": true,
"processor_res": 512,
"save_detected_map": true,
"input_image": "string",
"control_mode": "My prompt is more important"
},
{
"enabled": true,
"model": "control_instant_id_sdxl [c5c25a50]",
"module": "instant_id_face_keypoints",
"weight": 1,
"resize_mode": "Crop and Resize",
"guidance_start": 0,
"guidance_end": 1,
"pixel_perfect": true,
"processor_res": 512,
"save_detected_map": true,
"input_image": "string",
"control_mode": "ControlNet is more important"
}
]
}
}
}

@ -0,0 +1,57 @@
{
"override_settings": {
"sd_model_checkpoint": "SDXL古风汉服MAX_v1.0.safetensors [ba140e252c]",
"sd_vae": "Automatic"
},
"prompt": "(photorealistic, best quality, ultra high res, extremely detailed eyes and face:1.3),(1girl, solo:1.3),skirt,jewelry,long_hair,necklace,earrings,perfect body,standing,large breasts,looking at viewer,chinese clothes,china dress,hanfu,",
"negative_prompt": "NSFW,blurry,low quality,watermark,monochrome,badhandv4,easynegative,ng_deepnegative_v1_75t,bad proportions,mutated hands and fingers,poorly drawn face,extra limb,missing limb,malformed limbs,disconnected limbs,ugly,floating limbs,extra legs,mutation,bad body,long neck,cross-eyed,text,cleavage,",
"steps": 25,
"sampler_name": "DPM++ 2M Karras",
"width": 1024,
"height": 1472,
"batch_size": 1,
"n_iter": 1,
"seed": 1,
"cfg_scale": 7,
"CLIP_stop_at_last_layers": 2,
"init_images": [
"string"
],
"restore_faces": false,
"enable_hr": true,
"denoising_strength": 0.5,
"alwayson_scripts": {
"ControlNet": {
"args": [
{
"enabled": true,
"model": "ip-adapter_instant_id_sdxl [eb2d3ec0]",
"module": "instant_id_face_embedding",
"weight": 1,
"resize_mode": "Crop and Resize",
"guidance_start": 0,
"guidance_end": 1,
"pixel_perfect": true,
"processor_res": 512,
"save_detected_map": true,
"input_image": "string",
"control_mode": "My prompt is more important"
},
{
"enabled": true,
"model": "control_instant_id_sdxl [c5c25a50]",
"module": "instant_id_face_keypoints",
"weight": 1,
"resize_mode": "Crop and Resize",
"guidance_start": 0,
"guidance_end": 1,
"pixel_perfect": true,
"processor_res": 512,
"save_detected_map": true,
"input_image": "string",
"control_mode": "ControlNet is more important"
}
]
}
}
}

@ -0,0 +1,57 @@
{
"override_settings": {
"sd_model_checkpoint": "SDXL古风汉服MAX_v1.0.safetensors [ba140e252c]",
"sd_vae": "Automatic"
},
"prompt": "(photorealistic, best quality, ultra high res, extremely detailed eyes and face:1.3),(1girl, solo:1.3),skirt,jewelry,long_hair,necklace,earrings,perfect body,standing,large breasts,looking at viewer,chinese clothes,china dress,hanfu,",
"negative_prompt": "NSFW,blurry,low quality,watermark,monochrome,badhandv4,easynegative,ng_deepnegative_v1_75t,bad proportions,mutated hands and fingers,poorly drawn face,extra limb,missing limb,malformed limbs,disconnected limbs,ugly,floating limbs,extra legs,mutation,bad body,long neck,cross-eyed,text,cleavage,",
"steps": 25,
"sampler_name": "DPM++ 2M Karras",
"width": 1024,
"height": 1472,
"batch_size": 1,
"n_iter": 1,
"seed": 1,
"cfg_scale": 7,
"CLIP_stop_at_last_layers": 2,
"init_images": [
"string"
],
"restore_faces": false,
"enable_hr": true,
"denoising_strength": 0.5,
"alwayson_scripts": {
"ControlNet": {
"args": [
{
"enabled": true,
"model": "ip-adapter_instant_id_sdxl [eb2d3ec0]",
"module": "instant_id_face_embedding",
"weight": 1,
"resize_mode": "Crop and Resize",
"guidance_start": 0,
"guidance_end": 1,
"pixel_perfect": true,
"processor_res": 512,
"save_detected_map": true,
"input_image": "string",
"control_mode": "My prompt is more important"
},
{
"enabled": true,
"model": "control_instant_id_sdxl [c5c25a50]",
"module": "instant_id_face_keypoints",
"weight": 1,
"resize_mode": "Crop and Resize",
"guidance_start": 0,
"guidance_end": 1,
"pixel_perfect": true,
"processor_res": 512,
"save_detected_map": true,
"input_image": "string",
"control_mode": "ControlNet is more important"
}
]
}
}
}

@ -0,0 +1,57 @@
{
"override_settings": {
"sd_model_checkpoint": "SDXL古风汉服MAX_v1.0.safetensors [ba140e252c]",
"sd_vae": "Automatic"
},
"prompt": "(photorealistic, best quality, ultra high res, extremely detailed eyes and face:1.3),(1girl, solo:1.3),skirt,jewelry,long_hair,necklace,earrings,perfect body,standing,large breasts,looking at viewer,chinese clothes,china dress,hanfu,",
"negative_prompt": "NSFW,blurry,low quality,watermark,monochrome,badhandv4,easynegative,ng_deepnegative_v1_75t,bad proportions,mutated hands and fingers,poorly drawn face,extra limb,missing limb,malformed limbs,disconnected limbs,ugly,floating limbs,extra legs,mutation,bad body,long neck,cross-eyed,text,cleavage,",
"steps": 25,
"sampler_name": "DPM++ 2M Karras",
"width": 1024,
"height": 1472,
"batch_size": 1,
"n_iter": 1,
"seed": 1,
"cfg_scale": 7,
"CLIP_stop_at_last_layers": 2,
"init_images": [
"string"
],
"restore_faces": false,
"enable_hr": true,
"denoising_strength": 0.5,
"alwayson_scripts": {
"ControlNet": {
"args": [
{
"enabled": true,
"model": "ip-adapter_instant_id_sdxl [eb2d3ec0]",
"module": "instant_id_face_embedding",
"weight": 1,
"resize_mode": "Crop and Resize",
"guidance_start": 0,
"guidance_end": 1,
"pixel_perfect": true,
"processor_res": 512,
"save_detected_map": true,
"input_image": "string",
"control_mode": "My prompt is more important"
},
{
"enabled": true,
"model": "control_instant_id_sdxl [c5c25a50]",
"module": "instant_id_face_keypoints",
"weight": 1,
"resize_mode": "Crop and Resize",
"guidance_start": 0,
"guidance_end": 1,
"pixel_perfect": true,
"processor_res": 512,
"save_detected_map": true,
"input_image": "string",
"control_mode": "ControlNet is more important"
}
]
}
}
}

@ -0,0 +1,57 @@
{
"override_settings": {
"sd_model_checkpoint": "SDXL古风汉服MAX_v1.0.safetensors [ba140e252c]",
"sd_vae": "Automatic"
},
"prompt": "(photorealistic, best quality, ultra high res, extremely detailed eyes and face:1.3),(1girl, solo:1.3),skirt,jewelry,long_hair,necklace,earrings,perfect body,standing,large breasts,looking at viewer,chinese clothes,china dress,hanfu,",
"negative_prompt": "NSFW,blurry,low quality,watermark,monochrome,badhandv4,easynegative,ng_deepnegative_v1_75t,bad proportions,mutated hands and fingers,poorly drawn face,extra limb,missing limb,malformed limbs,disconnected limbs,ugly,floating limbs,extra legs,mutation,bad body,long neck,cross-eyed,text,cleavage,",
"steps": 25,
"sampler_name": "DPM++ 2M Karras",
"width": 1024,
"height": 1472,
"batch_size": 1,
"n_iter": 1,
"seed": 1,
"cfg_scale": 7,
"CLIP_stop_at_last_layers": 2,
"init_images": [
"string"
],
"restore_faces": false,
"enable_hr": true,
"denoising_strength": 0.5,
"alwayson_scripts": {
"ControlNet": {
"args": [
{
"enabled": true,
"model": "ip-adapter_instant_id_sdxl [eb2d3ec0]",
"module": "instant_id_face_embedding",
"weight": 1,
"resize_mode": "Crop and Resize",
"guidance_start": 0,
"guidance_end": 1,
"pixel_perfect": true,
"processor_res": 512,
"save_detected_map": true,
"input_image": "string",
"control_mode": "My prompt is more important"
},
{
"enabled": true,
"model": "control_instant_id_sdxl [c5c25a50]",
"module": "instant_id_face_keypoints",
"weight": 1,
"resize_mode": "Crop and Resize",
"guidance_start": 0,
"guidance_end": 1,
"pixel_perfect": true,
"processor_res": 512,
"save_detected_map": true,
"input_image": "string",
"control_mode": "ControlNet is more important"
}
]
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 519 KiB

@ -7,5 +7,36 @@ input_source_img = '../Image/1ae93e2587822c291362abf9504cb49ec.jpeg'
# 输出图片
output_file = "../Out/Result.png"
# 图生图函数
def img2img(url,model_id, prompt_id, input_source_img, output_file):
# JSON文件模板
templet_file = r'../JSON/' + str(model_id) + '_' + str(prompt_id) + '.json'
# 模型图片
input_refer_img = '../Image/' + str(model_id) + '/' + str(prompt_id) + '.jpg'
# 读取JSON文件
with open(templet_file, 'r', encoding='utf-8') as file:
payload = json.load(file)
# 用户输入的图片
source_img = encode_image(input_source_img)
# 模型固定的参考图片
refer_img = encode_image(input_refer_img)
# 在ControlNet的第一个图片中使用用户输入的图片用此图片的人脸进行换脸操作
payload["alwayson_scripts"]["ControlNet"]["args"][0]["input_image"] = source_img
# 图生图,风格参考图是输入
payload["init_images"] = [refer_img]
payload["alwayson_scripts"]["ControlNet"]["args"][1]["input_image"] = refer_img
# 调用SD服务
response = requests.post(url=f'{url}/sdapi/v1/img2img', json=payload)
if response.status_code != 200:
print(response.text)
exit(0)
r = response.json()
# 保存图片
save_encoded_image(response.json()['images'][0], output_file)
# 调用图生图
img2img(url, 28, 1, input_source_img, output_file)

@ -104,33 +104,3 @@ def split_4_image(image_path, out_path):
return res
# 图生图函数
def img2img(url,model_id, prompt_id, input_source_img, output_file):
# JSON文件模板
templet_file = r'../JSON/' + str(model_id) + '_' + str(prompt_id) + '.json'
# 模型图片
input_refer_img = '../Image/' + str(model_id) + '/' + str(prompt_id) + '.jpg'
# 读取JSON文件
with open(templet_file, 'r', encoding='utf-8') as file:
payload = json.load(file)
# 用户输入的图片
source_img = encode_image(input_source_img)
# 模型固定的参考图片
refer_img = encode_image(input_refer_img)
# 在ControlNet的第一个图片中使用用户输入的图片用此图片的人脸进行换脸操作
payload["alwayson_scripts"]["ControlNet"]["args"][0]["input_image"] = source_img
# 图生图,风格参考图是输入
payload["init_images"] = [refer_img]
payload["alwayson_scripts"]["ControlNet"]["args"][1]["input_image"] = refer_img
# 调用SD服务
response = requests.post(url=f'{url}/sdapi/v1/img2img', json=payload)
if response.status_code != 200:
print(response.text)
exit(0)
r = response.json()
# 保存图片
save_encoded_image(response.json()['images'][0], output_file)

@ -64,26 +64,33 @@ def webui_txt_2_img(model_id, json_data, input_image):
# 图生图服务调用
def webui_img_2_img(model_id, json_data, input_image):
def webui_img_2_img(model_id, prompt_id, json_data, input_image):
# 提示词
prompt = json_data['prompt']
# 图片
args = json_data['alwayson_scripts']['ControlNet']['args']
pose_image = json_data['pose_image']
args[0]['input_image'] = encode_image(input_image[0])
# 如果有特殊的姿态要求,那就用模板指定的姿态图
if len(pose_image) > 0:
if len(args) > 1:
args[1]['input_image'] = encode_image(pose_image)
else: # 如果没有特殊的姿态要求,那么就统一用一张图片
if len(args) > 1:
args[1]['input_image'] = encode_image(input_image[0])
# 用户输入的图片
source_img = encode_image(input_image[0])
# 模型固定的参考图片
refer_source_img = r'./Image/' + str(model_id) + '/' + str(prompt_id) + '.jpg'
if not os.path.exists(refer_source_img):
refer_source_img = r'./Image/' + str(model_id) + '/' + str(prompt_id) + '.png'
# 都找不到,报错
if not os.path.exists(refer_source_img):
print("模型:" + str(model_id) + ",参考图:" + str(prompt_id) + "不存在,请检查!")
exit(0)
# 找到参考图
refer_img = encode_image(refer_source_img)
# 在ControlNet的第一个图片中使用用户输入的图片用此图片的人脸进行换脸操作
json_data["alwayson_scripts"]["ControlNet"]["args"][0]["input_image"] = source_img
# 图生图,风格参考图是输入
json_data["init_images"] = [refer_img]
json_data["alwayson_scripts"]["ControlNet"]["args"][1]["input_image"] = refer_img
# 宽度与高度
width = json_data['width']
height = json_data['height']
# 提示词
json_data['prompt'] = prompt
# 开始生成图片
printf("开始生成图片...")
@ -268,7 +275,7 @@ def get_task():
vjson_data = json.load(file)
# 利用三元表达式输出
printf("发现需要处理的" + ("WebUI" if model_type_id == 1 else "ComfyUI") + "任务,model_id=" + str(
printf("发现需要处理的" + ("WebUI" if model_type_id in [1, 3] else "ComfyUI") + "任务,model_id=" + str(
model_id) + ",task_id=" + str(task_id))
# SD_TXT2IMG
@ -283,7 +290,7 @@ def get_task():
# SD_IMG2IMG
if model_type_id == 3:
webui_img_2_img(model_id=model_id, json_data=vjson_data, input_image=input_image)
webui_img_2_img(model_id=model_id, prompt_id=prompt_id, json_data=vjson_data, input_image=input_image)
return task_id
elif success == 0:

Loading…
Cancel
Save