parent
7408bfbd42
commit
7a8534055f
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 365 KiB |
@ -0,0 +1,34 @@
|
||||
"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": "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": false,
|
||||
"input_image": "{{input_image2}}",
|
||||
"control_mode": "ControlNet is more important"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
{
|
||||
"prompt": "(8k, RAW photo, highest quality),hyperrealistic abstract style portrait of an otherworldly being with metallic skin,glowing orbs for eyes,and intricate fractal patterns emanating from their face,non-representational,colors and shapes,expression of feelings,imaginative,highly detailed,(pink Fluorescent eyeshadow:1.2),eyeliner,makeup,lipstick,watery eyes,(Mole under eye:1.2),(seductive_smile:1.2),XURE Dunhuang Flying XL,1girl,<lora:绪儿 敦煌飞天XL:0.6>,",
|
||||
"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,",
|
||||
"seed": -1,
|
||||
"sampler_name": "DPM++ 2M Karras",
|
||||
"batch_size": 1,
|
||||
"n_iter": 1,
|
||||
"steps": 20,
|
||||
"cfg_scale": 3,
|
||||
"width": 1024,
|
||||
"height": 1472,
|
||||
"restore_faces": true,
|
||||
"tiling": true,
|
||||
"do_not_save_samples": false,
|
||||
"do_not_save_grid": false,
|
||||
"eta": 0,
|
||||
"denoising_strength": 0.5,
|
||||
"s_min_uncond": 0,
|
||||
"s_churn": 0,
|
||||
"s_tmax": 0,
|
||||
"s_tmin": 0,
|
||||
"s_noise": 0,
|
||||
"override_settings": {},
|
||||
"override_settings_restore_afterwards": true,
|
||||
"refiner_switch_at": 0,
|
||||
"disable_extra_networks": false,
|
||||
"comments": {},
|
||||
"init_images": [
|
||||
"string"
|
||||
],
|
||||
"resize_mode": 0,
|
||||
"image_cfg_scale": 0,
|
||||
"inpainting_fill": 0,
|
||||
"inpaint_full_res": true,
|
||||
"inpaint_full_res_padding": 0,
|
||||
"inpainting_mask_invert": 0,
|
||||
"initial_noise_multiplier": 0,
|
||||
"include_init_images": false,
|
||||
"script_args": [],
|
||||
"send_images": true,
|
||||
"save_images": false
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
{
|
||||
"prompt": "(8k, RAW photo, highest quality),hyperrealistic abstract style portrait of an otherworldly being with metallic skin,glowing orbs for eyes,and intricate fractal patterns emanating from their face,non-representational,colors and shapes,expression of feelings,imaginative,highly detailed,(pink Fluorescent eyeshadow:1.2),eyeliner,makeup,lipstick,watery eyes,(Mole under eye:1.2),(seductive_smile:1.2),XURE Dunhuang Flying XL,1girl,<lora:绪儿 敦煌飞天XL:0.6>,",
|
||||
"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,",
|
||||
"styles": [
|
||||
"string"
|
||||
],
|
||||
"seed": -1,
|
||||
"subseed": -1,
|
||||
"subseed_strength": 0,
|
||||
"seed_resize_from_h": -1,
|
||||
"seed_resize_from_w": -1,
|
||||
"sampler_name": "DPM++ 2M Karras",
|
||||
"batch_size": 1,
|
||||
"n_iter": 1,
|
||||
"steps": 20,
|
||||
"cfg_scale": 3,
|
||||
"width": 1024,
|
||||
"height": 1472,
|
||||
"restore_faces": true,
|
||||
"tiling": true,
|
||||
"do_not_save_samples": false,
|
||||
"do_not_save_grid": false,
|
||||
"eta": 0,
|
||||
"denoising_strength": 0.5,
|
||||
"s_min_uncond": 0,
|
||||
"s_churn": 0,
|
||||
"s_tmax": 0,
|
||||
"s_tmin": 0,
|
||||
"s_noise": 0,
|
||||
"override_settings": {},
|
||||
"override_settings_restore_afterwards": true,
|
||||
"refiner_checkpoint": "string",
|
||||
"refiner_switch_at": 0,
|
||||
"disable_extra_networks": false,
|
||||
"firstpass_image": "string",
|
||||
"comments": {},
|
||||
"init_images": [
|
||||
"string"
|
||||
],
|
||||
"resize_mode": 0,
|
||||
"image_cfg_scale": 0,
|
||||
"mask": "string",
|
||||
"mask_blur_x": 4,
|
||||
"mask_blur_y": 4,
|
||||
"mask_blur": 0,
|
||||
"mask_round": true,
|
||||
"inpainting_fill": 0,
|
||||
"inpaint_full_res": true,
|
||||
"inpaint_full_res_padding": 0,
|
||||
"inpainting_mask_invert": 0,
|
||||
"initial_noise_multiplier": 0,
|
||||
"latent_mask": "string",
|
||||
"force_task_id": "string",
|
||||
"sampler_index": "Euler",
|
||||
"include_init_images": false,
|
||||
"script_name": "string",
|
||||
"script_args": [],
|
||||
"send_images": true,
|
||||
"save_images": false,
|
||||
"alwayson_scripts": {},
|
||||
"infotext": "string"
|
||||
}
|
@ -1,39 +1,33 @@
|
||||
from Util import ConfigUtil
|
||||
from Util.CommonUtil import *
|
||||
|
||||
|
||||
# 图生图
|
||||
def img2img(url, img_path, v_data, save_path):
|
||||
image = encode_image(img_path)
|
||||
v_data['init_images'] = [image]
|
||||
v_data['alwayson_scripts']['controlnet']['args'][0]['image'] = image
|
||||
response = submit_post(url, v_data)
|
||||
save_encoded_image(response.json()['images'][0], save_path)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# 配置文件
|
||||
config = ConfigUtil.getConfig()
|
||||
# 图生图服务地址
|
||||
img2img_url = config['webui']['img2img_url']
|
||||
|
||||
# 图片路径
|
||||
image_path = "../Image/mote.png"
|
||||
# 用户传的源图
|
||||
source_img = "../Image/1ae93e2587822c291362abf9504cb49ec.jpeg"
|
||||
|
||||
# 参照图片路径
|
||||
refer_img = "../Image/28/1.jpg"
|
||||
|
||||
# 生成的JSON文件
|
||||
data = \
|
||||
{
|
||||
"init_images": [],
|
||||
"sampler_name": "Euler",
|
||||
"alwayson_scripts": {
|
||||
"controlnet": {
|
||||
"args": [
|
||||
{
|
||||
"image": "",
|
||||
"module": "none", "model": "control_openpose-fp16 [9ca67cc5]",
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
img2img(img2img_url, image_path, data, "../Out/result.png")
|
||||
# print(json.dumps(data, sort_keys=True, ensure_ascii=False)) # 生成可以正确显示中文的json格式输出
|
||||
with open("../JSON/28_1.json", 'r', encoding='utf-8') as f:
|
||||
v_data = json.load(f)
|
||||
|
||||
# 源图
|
||||
source_image = encode_image(source_img)
|
||||
refer_image = encode_image(refer_img)
|
||||
# https://blog.csdn.net/wangwenzhe222/article/details/139059131
|
||||
# ControlNet
|
||||
#v_data['alwayson_scripts']['ControlNet']['args'][0]['image'] = source_image
|
||||
#v_data['alwayson_scripts']['ControlNet']['args'][1]['image'] = refer_image
|
||||
v_data['init_images'] = [refer_image]
|
||||
|
||||
#print(json.dumps(v_data, sort_keys=True, ensure_ascii=False,indent=4)) # 生成可以正确显示中文的json格式输出
|
||||
|
||||
response = submit_post(img2img_url, v_data)
|
||||
save_encoded_image(response.json()['images'][0], "../Out/result.png")
|
||||
|
||||
|
Loading…
Reference in new issue