Failed to swap face in postprocess method : apply_overlay() takes 3 positional arguments but 4 were given #171
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Please remember that the bug report section is not a forum. Before submitting a bug, ensure you have read the FAQ thoroughly. This helps us maintain an efficient bug tracking process. Thank you for your understanding and cooperation. Use the discussion section for anything else.
Describe the bug
Using stable-diffusion-webui-forge face is not swapped and error in the title is shown in the terminal :
To Reproduce
Steps to reproduce the behavior:
Expected behavior
face is swapped, no error.
Screenshots
none
Desktop (please complete the following information):
Additional context
Works 100% in stable-diffusion-webui.
Same here in Automatic1111 v1.8.0-RC-4-gc7808825
Exactly the same. The only difference is the OS is Win 10 for me
Only happens in img2img for me
issue on stable-diffusion-webui-forge FaceSwapLab support #274
i did get this to work by checking swap in source face (blended face) and removing the next checkbox.
https://github.com/lllyasviel/stable-diffusion-webui-forge/issues/274#issuecomment-1974829006
yeah this works but that isnt the problem, i think they are trying to use the other option which switches the face after the generation.
Facing the same issue with img2img after recent update today
Traceback (most recent call last): File "D:\stable-diffusion-webui\extensions\sd-webui-faceswaplab\scripts\faceswaplab.py", line 201, in postprocess swp_img = imgutils.apply_mask(swp_img, p, batch_index) File "D:\stable-diffusion-webui\extensions\sd-webui-faceswaplab\scripts\faceswaplab_utils\imgutils.py", line 224, in apply_mask img = processing.apply_overlay(img, p.paste_to, batch_index, p.overlay_images) TypeError: apply_overlay() takes 3 positional arguments but 4 were givenAfter messing with all the settings over and over again, it only happens when you have "Swap in generated image" ticked in i2i.
I don't know anything about programming so I'm hoping someone or the dev fixes this soon.
yes, you need to check the first option "Swap in source image (blended face)" to make it work, but rendering is a bit different
Rendering is different but, from what I've noticed, is terribly inaccurate compared to just using the "swap in generated image" tick. A couple days ago it worked fine - now not so much.
In the interim, I've just been using the dedicated faceswaplab tab. My work flow has changed to "finish everything but that" and then just do the rest from there.
Check my alternative solution in another thread of the same topic -> #178
Works for me on a1111 1.8.0
Many thanks @antorio looks like it just works!
changes in /whatever/stable-diffusion-webui/extensions/sd-webui-faceswaplab/scripts/faceswaplab_utils/imgutils.py
fixed for now!
The fix above only works in the img2img tab.
in txt2txt tab faceswaplab is still broken.
Fixed for me in Txt2img also
in imgutils.py check the line ident
and just quote this line :
# img = processing.apply_overlay(img, p.paste_to, batch_index, p.overlay_images)Your code should look like :
for me doesnt work ... after edit the file, same issue ...
hopfully wait for an update ;)
@ncandelier many thanks! Works in txtimg and img2img now.
/whatever/stable-diffusion-webui/extensions/sd-webui-faceswaplab/scripts/faceswaplab_utils/imgutils.py edited and at line 224 code is like this now :
Hey, I am still having this issue in July 2024 using auto 1111. I just installed a few days ago from the install from URL. Was there ever a definitive solution? I know that it was marked completed, but I still have it.
2024-07-09 23:29:53,819 - FaceSwapLab - ERROR - Failed to swap face in postprocess method : apply_overlay() takes 3 positional arguments but 4 were given
Traceback (most recent call last):
File "D:\Stable Diffusion\stable-diffusion-webui\extensions\sd-webui-faceswaplab\scripts\faceswaplab.py", line 201, in postprocess
swp_img = imgutils.apply_mask(swp_img, p, batch_index)
File "D:\Stable Diffusion\stable-diffusion-webui\extensions\sd-webui-faceswaplab\scripts\faceswaplab_utils\imgutils.py", line 224, in apply_mask
img = processing.apply_overlay(img, p.paste_to, batch_index, p.overlay_images)
TypeError: apply_overlay() takes 3 positional arguments but 4 were given
It works most of the time in txt2img, but this is a dissapointing bug as img to img with inpainting is useful.
use
sd-webui-reactor .. all working fine (same base programmig)
https://github.com/Gourieff/sd-webui-reactor
read my article for even better faces ;)
https://civitai.com/articles/5002/face-swap-with-adetailer-and-reactor
looks like an update changed processing.py (stablediffusionfolder\modules\processing.py) and changed apply_overlay to accept 3 arguments and faceswaplabs hasn't been updated to use the new function in img2img (though it's updated elsewhere).
Rather than going through to see how to set up the args properly I just swapped in the old apply_overlay right under the new one in stablediffusionfolder\modules\processing.py and changed it to apply_overlay_legacy and then in extensions\sd-webui-faceswaplab\scripts\faceswaplab_utils\imgutils.py I modified it to reference the new _legacy function.
Under the apply_overlay function (around line 90, pasted this
`def apply_overlay_legacy(image, paste_loc, index, overlays):
if overlays is None or index >= len(overlays):
return image
Then modified extensions\sd-webui-faceswaplab\scripts\faceswaplab_utils\imgutils.py line 224 to this:
img = processing.apply_overlay_legacy(img, p.paste_to, batch_index, p.overlay_images)ymmv but seems to work for me.
@JonSingleton solution works; just be careful with the spacing - his code block got broken in the comment.
https://pastebin.com/8EaZvpTr - it should look like this, at least I think so because it works