With just one api function, img2img takes a new image and fixes the face right away #664
Unanswered
joseph16388
asked this question in
Q&A
Replies: 1 comment 2 replies
-
To produce a new image and fix the face at the same time using the import requests
# Define the URL for the ADetailer API
url = "http://your-adetailer-api-endpoint"
# Define the payload for the request
payload = {
"prompt": tag,
"negative_prompt": negative_prompt,
"sampler_name": main_app.configs.sampler_name,
"batch_size": 1,
"n_iter": 1,
"steps": main_app.configs.steps,
"cfg_scale": main_app.configs.cfg_scale,
"width": main_app.configs.width,
"height": main_app.configs.height,
"do_not_save_grid": "true",
"denoising_strength": main_app.configs.denoising_strength,
"init_images": [init_image_base64],
"alwayson_scripts": {
"ADetailer": {
"args": [
{
"ad_model": "face_yolov8n.pt",
"ad_prompt": tag,
"ad_negative_prompt": negative_prompt,
"ad_confidence": 0.5,
"ad_mask_min_ratio": 0.01,
"ad_mask_max_ratio": 1.0,
"ad_mask_merge_invert": "None",
"ad_inpaint_only_masked": True,
"ad_restore_face": True,
"ad_steps": 28,
"ad_cfg_scale": 7.0,
"ad_sampler": "DPM++ 2M Karras"
}
]
}
},
"override_settings": {
"sd_model_checkpoint": main_app.configs.checkpoint,
"sd_vae": main_app.configs.vae
}
}
# Send the request to the ADetailer API
response = requests.post(url, json=payload)
# Check the response
if response.status_code == 200:
result = response.json()
# Process the result as needed
print("Image and face fixed successfully.")
else:
print("Failed to process the image:", response.text) Ensure that the |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wanted to use the adetailer API in img2img to repair images directly as they are generated, so I used the following request dictionary:
novel_dict = {
"prompt": tag,
"negative_prompt": negative_prompt,
"sampler_name": main_app.configs.sampler_name,
"batch_size": 1,
"n_iter": 1,
"steps": main_app.configs.steps,
"cfg_scale": main_app.configs.cfg_scale,
"width": main_app.configs.width,
"height": main_app.configs.height,
"do_not_save_grid": "true",
"denoising_strength": main_app.configs.denoising_strength,
"init_images": [init_image_base64],
"alwayson_scripts": {
"ADetailer": {
"args": [
{
"ad_model": "face_yolov8n.pt"
},
]
}
},
"override_settings": {
"sd_model_checkpoint": main_app.configs.checkpoint,
"sd_vae": main_app.configs.vae
},
}
No images are produced, but when denoising_strength is 0 it is possible to produce a fixed image of the face, but there is no img2img a new image, which is not what I want. What I want is to produce a new image and fix the face at the same time, but following the novel_dict request above doesn't do that!
@DosuBot
Beta Was this translation helpful? Give feedback.
All reactions