main
黄海 1 year ago
parent ecc5b7afd5
commit 9baabdfdaa

@ -1,34 +1,57 @@
{ {
"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>,", "override_settings": {
"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,", "sd_model_checkpoint": "绪儿-一青十色XL_V2 VAE.safetensors [9f9290ac66]",
"seed": -1, "sd_vae": "Automatic"
"styles": [ },
"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,",
"sampler_name": "DPM++ 2M Karras", "steps": 20,
"batch_size": 1, "sampler_name": "DPM++ 2M Karras",
"n_iter": 1, "width": 1024,
"steps": 30, "height": 1472,
"cfg_scale": 3, "batch_size": 1,
"width": 1024, "n_iter": 1,
"height": 1472, "seed": 1,
"restore_faces": false, "cfg_scale": 3,
"do_not_save_samples": false, "CLIP_stop_at_last_layers": 2,
"do_not_save_grid": false, "init_images": [
"denoising_strength": 0.5, "string"
"s_noise": 1, ],
"override_settings": {}, "restore_faces": false,
"override_settings_restore_afterwards": true, "enable_hr": true,
"init_images": [ "denoising_strength": 0.5,
"string" "alwayson_scripts": {
], "ControlNet": {
"resize_mode": 0, "args": [
"image_cfg_scale": 0, {
"inpainting_fill": 0, "enabled": true,
"inpaint_full_res": true, "model": "ip-adapter_instant_id_sdxl [eb2d3ec0]",
"inpaint_full_res_padding": 0, "module": "instant_id_face_embedding",
"initial_noise_multiplier": 0, "weight": 1,
"include_init_images": false, "resize_mode": "Crop and Resize",
"send_images": true, "guidance_start": 0,
"save_images": false "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"
}
]
}
}
} }

@ -1,7 +1,5 @@
import requests
import io
import base64 import base64
from PIL import Image import json
def encode_image(image_path): def encode_image(image_path):
@ -10,80 +8,32 @@ def encode_image(image_path):
return b64.decode("utf-8") return b64.decode("utf-8")
# 读取JSON文件
json_file = r'../JSON/28_1.json'
with open(json_file, 'r', encoding='utf-8') as file:
payload = json.load(file)
# 此处为读取一张图片作为输入图像
refer_img = encode_image('../Image/28/1.jpg')
source_img = encode_image('../Image/1ae93e2587822c291362abf9504cb49ec.jpeg')
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
print(json.dumps(payload, sort_keys=False, ensure_ascii=False, indent=4)) # 生成可以正确显示中文的json格式输出
# API地址 # API地址
url = "http://192.168.1.21:7860" url = "http://192.168.1.21:7860"
# 提示词 # response = requests.post(url=f'{url}/sdapi/v1/img2img', json=payload)
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,"
# 此处为读取一张图片作为输入图像 # if response.status_code != 200:
encoded_image = encode_image('../Image/28/1.jpg') # print(response.text)
encoded_source_image = encode_image('../Image/1ae93e2587822c291362abf9504cb49ec.jpeg') # exit(0)
# r = response.json()
payload = { # image = Image.open(io.BytesIO(base64.b64decode(r['images'][0])))
# 模型设置
"override_settings": {
"sd_model_checkpoint": "绪儿-一青十色XL_V2 VAE.safetensors [9f9290ac66]",
"sd_vae": "Automatic"
},
# 基本参数
"prompt": prompt,
"negative_prompt": negative_prompt,
"steps": 20,
"sampler_name": "DPM++ 2M Karras",
"width": 1024,
"height": 1472,
"batch_size": 1,
"n_iter": 1,
"seed": 1,
"cfg_scale": 3,
"CLIP_stop_at_last_layers": 2,
"init_images": [encoded_image],
# 面部修复 face fix
"restore_faces": False,
# 高清修复 highres fix
"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": encoded_source_image,
"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": encoded_image,
"control_mode": "ControlNet is more important"
}
]
}
}
}
response = requests.post(url=f'{url}/sdapi/v1/img2img', json=payload)
r = response.json()
image = Image.open(io.BytesIO(base64.b64decode(r['images'][0])))
image.show() # print(payload)
image.save('output.png') # image.show()
# image.save('output.png')

Loading…
Cancel
Save